"Only Shrink Larger" in the C api?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jmhodges

"Only Shrink Larger" in the C api?

Post by jmhodges »

Hey,

I've noticed that `mogrify -resize 500x500> image.jpg` seems to do more than a simple:

Code: Select all

if (new_cols > max_col_size) {
    new_cols = max_side_size;
}

if (new_rows > max_row_size) {
    new_rows = max_side_size;
}
However, I can't figure out by looking at the mogrify.c code what exactly it's doing. The flags returned by ParseMetaGeometry that include the '>' (mapped to GreaterValue?) seem to be thrown away, and, yet, the image is created in a much better fashion that the strict MagickAdaptiveResizeImage(wand, new_cols, new_rows). That is, it seems to be correctly checking the aspect, but I can't figure out where it's doing that!.

Where, exactly, is it doing that work? I'd love to use what I assume is an available API call than rewrite it myself.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: "Only Shrink Larger" in the C api?

Post by magick »

You can pass "500x500>" as a string directly to MagickTransformImage() (MagickWand API) or TransformImage() (MagickCore API).
jmhodges

Re: "Only Shrink Larger" in the C api?

Post by jmhodges »

Yep, that worked. I wish the API was a little less strange, but TransformImage is crazy huge. Thanks.
Post Reply