ConvertImageCommand alway return MagickFalse

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Posts: 1
Joined: 2013-01-10T01:17:47-07:00
Authentication code: 6789

ConvertImageCommand alway return MagickFalse

Post by boygiandi »


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) {
    ImageInfo *imageInfo = AcquireImageInfo();
    ExceptionInfo *exceptionInfo = AcquireExceptionInfo();
    // ConvertImageCommand(ImageInfo *, int, char **, char **, MagickExceptionInfo *);
    status = ConvertImageCommand(imageInfo, 5, argv, NULL, exceptionInfo);
    if (exceptionInfo->severity != UndefinedException)

    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];
It can create a thumbnail and the output_image ( tmp_folder/test_iphone.png ) was generated success.
But the ConvertImageCommand alway return MagickFalse ( It alway print "Error in call" )

How to fix it ?

Post Reply