I'm using the MagickWand API in the iOS port of ImageMagick to encode animated gifs on an iPhone 4 and I'm finding the performance to be so slow that I suspect there might be something wrong in my code or perhaps I'm using the wrong API calls.
Here is the applicable code:
Code: Select all
MagickWand *gifWand = NewMagickWand();
MagickSetFormat( gifWand, "gif" );
for (UIImage *img in previewFrames) {
MagickWand *imgWand = NewMagickWand();
NSData *data = UIImageJPEGRepresentation( img, 0.7 );
MagickReadImageBlob( imgWand, [data bytes], [data length] );
MagickSetImageDelay( imgWand, delay );
MagickAddImage( gifWand, imgWand );
DestroyMagickWand( imgWand );
}
size_t gifSize;
unsigned char * gifBytes = MagickGetImagesBlob( gifWand, &gifSize );
NSData *gifData = [[NSData alloc] initWithBytes:gifBytes length:gifSize];
free( gifBytes );
DestroyMagickWand( gifWand );
I'm not expecting desktop-level performance, but this is really quite slow... much slower than what I'm used to using the php version. Can anyone help?
-Aaron