Page 2 of 2

Re: distort bug?

Posted: 2010-06-08T20:31:24-07:00
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

Re: distort bug?

Posted: 2010-06-09T21:01:52-07:00
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. :\

Re: distort bug?

Posted: 2010-06-09T21:04:55-07:00
by fmw42
you seem to be correct. you should contact the iMagick developer about this.

Re: distort bug?

Posted: 2010-09-16T14:44:45-07:00
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(...);

Re: distort bug?

Posted: 2010-09-16T20:42:05-07:00
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').

Re: distort bug?

Posted: 2010-09-16T20:45:01-07:00
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.