Page 1 of 1

Change in extentImage behavior for new ImageMagick versions?

Posted: 2011-05-11T13:54:15-07:00
by pwnedd
Hi all,

I have some IMagick code which uses "extentImage" to pad an image and position it at one corning of the new expanded image. When testing on a system with a newer version of ImageMagick, however, the direction the offsets push the image seems to have changed.

In both cases I am using the same version of IMagick (3.0.1). The differening factor is the version of ImageMagick for which they were built against.

For example, to offset the example "rose" image by 100 pixels down and over, the following works for older versions of ImageMagick:

Code: Select all

<?php
    header("Content-type: image/png");
    $im = new Imagick();
    $im->newPseudoImage(70, 46, "magick:rose");
    $im->setImageFormat("png");
    $im->extentImage(256, 256, -100, -100);
    echo $im;
?>
With newer versions you would need to use "100" instead of "-100" for the x & y offsets to achieve the same effect.

Verion Info:

Old:
Version: ImageMagick 6.6.2-6 2010-12-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

New:
Version: ImageMagick 6.6.9-8 2011-05-05 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP

Any ideas why the behavior has changed? I would like to write code that is not dependent on the verison of IM installed. I could probably detect the version installed and use that to decide whether to use positive or negative offsets, but does anyone know of a better way? I know there is a similar method (setImageExtent) but that does not provide support for specifying which direction the padding should occur in.

Thanks,

Re: Change in extentImage behavior for new ImageMagick versi

Posted: 2011-07-23T18:33:06-07:00
by fmw42
Older version probably ignored the minus sign. Shifting down and to the right has always been Plus as far as I know. See http://www.imagemagick.org/Usage/crop/#extent

Re: Change in extentImage behavior for new ImageMagick versi

Posted: 2011-07-25T21:25:57-07:00
by anthony
Extent can also be simulated simply by creating the appropriate background image and then composing the source image onto that in the appropriate way. This is also how border, crop, flatten, mosaic, merge, and even trim, operators work too, just with different ways of calculating the background image size and offset.