Passing a jpeg size hint with MagickCore

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
roflson
Posts: 4
Joined: 2014-04-10T14:44:17-07:00
Authentication code: 6789

Passing a jpeg size hint with MagickCore

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Passing a jpeg size hint with MagickCore

Post by magick »

Try this:
  • DefineImageOption(image_info,"jpeg:size=128x128");
roflson
Posts: 4
Joined: 2014-04-10T14:44:17-07:00
Authentication code: 6789

Re: Passing a jpeg size hint with MagickCore

Post 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.
Post Reply