I'm using Image Magick for my Iphone app and I got this error :
I use this code :
Code: Select all
- (void)posterizeImageWithCompression {
// Here we use JPEG compression.
NSLog(@"we're using JPEG compression");
// Get image from bundle.
char *input_image = strdup([[[NSBundle mainBundle] pathForResource:@"iphone" ofType:@"png"] UTF8String]);
char *output_image = strdup([[TMP stringByAppendingPathComponent:@"test_iphone.png"] UTF8String]);
char *argv[] = { "convert", input_image, "-resize", "200x200", output_image, NULL };
MagickCoreGenesis(*argv, MagickFalse);
magick_wand = NewMagickWand();
NSData * dataObject = UIImagePNGRepresentation([UIImage imageNamed:@"iphone.png"]);
MagickBooleanType status;
status = MagickReadImageBlob(magick_wand, [dataObject bytes], [dataObject length]);
if (status == MagickFalse) {
ThrowWandException(magick_wand);
}
ImageInfo *imageInfo = AcquireImageInfo();
ExceptionInfo *exceptionInfo = AcquireExceptionInfo();
// ConvertImageCommand(ImageInfo *, int, char **, char **, MagickExceptionInfo *);
status = ConvertImageCommand(imageInfo, 5, argv, NULL, exceptionInfo);
if (exceptionInfo->severity != UndefinedException)
{
status=MagickTrue;
CatchException(exceptionInfo);
}
free(input_image);
free(output_image);
if (status == MagickFalse) {
fprintf(stderr, "Error in call\n");
//ThrowWandException(magick_wand); // Always throws an exception here...
}
[imageViewButton setImage:[UIImage imageWithContentsOfFile:[TMP stringByAppendingPathComponent:@"test_iphone.png"]] forState:UIControlStateNormal];
}
But the ConvertImageCommand alway return MagickFalse ( It alway print "Error in call" )
How to fix it ?
Thanks.