Page 1 of 1

Passing a jpeg size hint with MagickCore

Posted: 2014-04-10T14:52:49-07:00
by roflson
I am resizing JPEGs, programatically with the MagickCore interface.

I note with the convert command that passing a size hint dramatically speeds up the resize:
convert -define jpeg:size=800x800 -resize=800x800 balloon.jpg b.jpg
I would like to pass this in to my MagickCore code, but I do not see how. This is my code:

Code: Select all

ImageInfo* original_image_info = AcquireImageInfo();
ExceptionInfo* ei = AcquireExceptionInfo();
Image* original_image = BlobToImage(original_image_info, ptr, sz, ei);
SyncImageSettings(original_image_info, original_image); // todo: needed?
Image* resized_image = AdaptiveResizeImage(original_image, width, height, ei);
I assume I need to add it to original_image_info (so it can be passed to the jpeg loader), but I cannot see where in the code to do so. :(

Thanks in advance.

Re: Passing a jpeg size hint with MagickCore

Posted: 2014-04-10T16:29:08-07:00
by magick
Try this:
  • DefineImageOption(image_info,"jpeg:size=128x128");

Re: Passing a jpeg size hint with MagickCore

Posted: 2014-04-10T17:00:59-07:00
by roflson
Thanks for the hint. Both of the following appear to work:

SetImageOption(original_image_info, "jpeg:size", "800x800");
DefineImageOption(original_image_info,"jpeg:size=800x800");

There are many ways to skin a cat.