How to force super sampling instead of EWA resampling for distort ?

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.
Post Reply
indiana
Posts: 2
Joined: 2015-09-23T07:48:24-07:00
Authentication code: 1151

How to force super sampling instead of EWA resampling for distort ?

Post by indiana »

hi everybody,

I'm working on a web application and I need with PHP to distort and tile an image, just as :
http://www.imagemagick.org/Usage/distorts/#horizon

But with a small process time, I need to render with interpolated lookup or super sampling x3 ou 4, as :
http://www.imagemagick.org/Usage/distor ... a_vs_super

I can do this with inline command (convert ... -virtual-pixel tile -filter point -set option:distort:scale 3 -distort perspective ...), but I found nowhere how do to with IMagick !

My code :

Code: Select all

$echant=new Imagick();
$echant->readImage('texture.jpg');
$echant->resizeImage(800,600,Imagick::FILTER_CATROM,1);
$echant->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TILE);
$echant->setImageMatte(true);
$echant->setImageMatteColor('black');
$echant->setImageFormat('png');
$echant->distortImage(Imagick::DISTORTION_PERSPECTIVE, array( 0,0, 2,285, 354,0, 161,266, 354,532, 347,474, 0,532, 15,528 ), false);
I try VIRTUALPIXELMETHOD_BACKGROUND to see a result quickly (it's working) and with setImageProperty('filter:point','option:distort:scale 3') and/or setImageArtifact('filter','point') but nothing work.

Help needed and greatly appreciated ! Thank in advance.

Indy.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to force super sampling instead of EWA resampling for distort ?

Post by snibgo »

I don't know IMagick. Perhaps it can't do "-set option:distort:scale 3".

A similar result comes from resizing the input up by 300% before distorting, and resizing down to the exact dimensions after. In my experiments, for a given factor, I find this gives a better quality than "option:distort:scale".
snibgo's IM pages: im.snibgo.com
indiana
Posts: 2
Joined: 2015-09-23T07:48:24-07:00
Authentication code: 1151

Re: How to force super sampling instead of EWA resampling for distort ?

Post by indiana »

Ok thank you for the tip, but to do that I need to "-filter Point" with $echant->distortImage() and I don't know how...
Post Reply