distort bug?

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: distort bug?

Post by fmw42 »

$im->setImageVirtualPixelMethod(imagick::VIRTUALPIXELMETHOD_BACKGROUND);
Are you sure this is correct and not just

$im->setImageVirtualPixelMethod(imagick::BACKGROUND);
or
$im->setImageVirtualPixelMethod(imagick::TRANSPARENT);


I looked at http://us2.php.net/imagick but it did not give the actual method options. Where did you see that it should be VIRTUALPIXELMETHOD_BACKGROUND or VIRTUALPIXELMETHOD_TRANSPARENT

Never mind, I see it at http://us2.php.net/manual/en/imagick.constants.php But what does the "integer" next to it mean? At the top of the page it says:

"The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime."

So perhaps all the constants are not loaded in your version or by your host?

You could try getImageVirtualPixelMethod and see what integer is returned, then try some other integers with set... and see what you get as a result or by using get...

see http://us2.php.net/manual/en/function.i ... method.php
esm723

Re: distort bug?

Post by esm723 »

I've actually already tried that (I posted that code in my first post in this thread).

Code: Select all

echo imagick::VIRTUALPIXELMETHOD_TRANSPARENT; 
echo $im->getImageVirtualPixelMethod();      // outputs 8 
$im->setImageVirtualPixelMethod(imagick::VIRTUALPIXELMETHOD_TRANSPARENT);  // sets the VP to what I want (8 in theory)
echo $im->getImageVirtualPixelMethod(); // does not output 8.  instead, it outputs 0, or imagick::VIRTUALPIXELMETHOD_UNDEFINED, which I assume points to the default imagick::VIRTUALPIXELMETHOD_EDGE
So, as you see, the first line successfully echos 8 (the integer for the imagick::VIRTUALPIXELMETHOD_TRANSPARENT constant). I then set the VirtualPixelMethod to that same constant, but when I echo getImageVirtualPixelMethod() again, it doesn't echo that constant. This, to me, says something is wrong with the setImageVirtualPixelMethod() method. :\
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: distort bug?

Post by fmw42 »

you seem to be correct. you should contact the iMagick developer about this.
bmason

Re: distort bug?

Post by bmason »

I figured out how to work around this. Draw a one-pixel transparent border around the image before distorting it by adding the command:

Code: Select all

  $testImagick->borderImage(new ImagickPixel("none"), 1, 1);
before

Code: Select all

$testImagick->distortImage(...);
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: distort bug?

Post by anthony »

NOTE to be able to use a Transparent VP the image should have alpha channel enabled.

This is not done automatically. Most operators don't.

Only a couple of composition methods (CopyOpacity, and ChangeMask), and GIF animation methods do ensure an alpha channel is present and enabled as transparency is inherent in the operator.

Distort does not enable transparency as that comes from the use of other settings, that may or may not effect the outcome of the operation. That is Distort does not know anything about virtual pixel handling.

The EWA resampling underneath distort, does know a little about VP, as part of some optimizations involving 'viewing distant horizons'. But for normal resampling even it does not deal with VP.

Virtual Pixel handling is actually done at an even lower level pixel lookup. I myself have added some VP handling methods (For example 'Checkerboard').
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: distort bug?

Post by anthony »

WARNING: do not rely on the actual 'number' used for the VP setting as being constant for all versions of IM. That number is not likely to change often, but may change if a new VP setting is added.

Some means of PHP constant export should be provided, and the PHP Magick API should be rebuilt if a newer version of IM is installed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply