Page 1 of 1

"Only Shrink Larger" in the C api?

Posted: 2010-08-14T17:06:59-07:00
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.

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

Posted: 2010-08-14T17:24:21-07:00
by magick
You can pass "500x500>" as a string directly to MagickTransformImage() (MagickWand API) or TransformImage() (MagickCore API).

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

Posted: 2010-08-16T07:31:39-07:00
by jmhodges
Yep, that worked. I wish the API was a little less strange, but TransformImage is crazy huge. Thanks.