-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize.c
73 lines (53 loc) · 1.63 KB
/
resize.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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <MagickWand/MagickWand.h>
void open(void);
char* resize(char *,char *);
void close(void);
int main()
{
char oldImage[100],newImage[100];
open();
resize(oldImage,newImage);
close();
return(0);
}
void open(){
MagickWandGenesis();//Starting Magick Wand Environment
}
void close(){
MagickWandTerminus();//Terminates the MagickWand environment
}
char* resize(char *oldImage,char *newImage){
MagickWand *magick_wand;
MagickBooleanType status;
char *description;
ExceptionType exceptiontype;
magick_wand=NewMagickWand();//Initialize the MagickWand
status=IsMagickWand(magick_wand);
if(status==MagickFalse){
description=MagickGetException(magick_wand,&exceptiontype);//Get the Exception of the MagickWand Methods
strcat(description,"\n\tMethod : NewMagickWand()" );
MagickClearException(magick_wand);
return description;
}
status=MagickReadImage(magick_wand,oldImage);//Read the Image
if(status==MagickFalse){
description=MagickGetException(magick_wand,&exceptiontype);
strcat(description,"\n\tMethod : MagickReadMethod()" );
MagickClearException(magick_wand);
return description;
}
status=MagickResizeImage(magick_wand,1600,1600,LanczosFilter);//Resize the image
if(status==MagickFalse){
description=MagickGetException(magick_wand,&exceptiontype);
strcat(description,"\n\tMethod : MagickResizeImage()" );
MagickClearException(magick_wand);
return description;
}
MagickWriteImage(magick_wand,newImage);//write the image
DestroyMagickWand(magick_wand);//Destroy the MagickWand
description="done";
return description;
}