-
Notifications
You must be signed in to change notification settings - Fork 0
/
resourceNewImage.c
93 lines (69 loc) · 2.51 KB
/
resourceNewImage.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
//#define IM7
#ifdef IM7
#include <MagickWand/MagickWand.h>
#else
#include <wand/MagickWand.h>
#endif
void ThrowWandException(MagickWand *wand) {
char *description;
ExceptionType severity;
description = MagickGetException(wand, &severity);
(void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
description=(char *) MagickRelinquishMemory(description);
exit(-1);
}
void checkResources() {
MagickSizeType resource_size;
MagickSetResourceLimit(MemoryResource, 50000ULL * 50000);
MagickSetResourceLimit(DiskResource, 50000ULL * 50000);
MagickSetResourceLimit(AreaResource, 50000ULL * 50000);
MagickSetResourceLimit(WidthResource, 50000ULL);
MagickSetResourceLimit(HeightResource, 50000ULL);
MagickSetResourceLimit(TimeResource, 100);
resource_size = MagickGetResourceLimit(MemoryResource);
printf("MemoryResource : %lu\n", resource_size);
resource_size = MagickGetResourceLimit(DiskResource);
printf("DiskResource : %lu\n", resource_size);
resource_size = MagickGetResourceLimit(AreaResource);
printf("AreaResource : %lu\n", resource_size);
resource_size = MagickGetResourceLimit(WidthResource);
printf("WidthResource : %lu\n", resource_size);
resource_size = MagickGetResourceLimit(HeightResource);
printf("HeightResource : %lu\n", resource_size);
resource_size = MagickGetResourceLimit(TimeResource);
printf("TimeResource : %lu\n", resource_size);
resource_size = MagickGetResourceLimit(MapResource);
printf("MapResource : %lu\n", resource_size);
}
int main(int argc,char **argv) {
MagickWand *magick_wand;
MagickBooleanType status;
PixelWand *pixel_wand;
MagickWandGenesis();
magick_wand = NewMagickWand();
//checkResources();
pixel_wand = NewPixelWand();
PixelSetColor(pixel_wand, "white");
status = MagickNewImage(magick_wand, 400, 200, pixel_wand);
if (status == MagickFalse) {
printf("Failed to MagickReadImage");
ThrowWandException(magick_wand);
return -1;
}
MagickSetImageFormat(magick_wand, "png");
status = MagickWriteImage(magick_wand, "./resource_new_output.png");
if (status == MagickFalse) {
printf("Failed to MagickWriteImages");
ThrowWandException(magick_wand);
return -1;
}
MagickWandTerminus();
return(0);
}