imagemagick command to IMagick problem

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
shirkavand
Posts: 8
Joined: 2013-02-04T08:06:40-07:00
Authentication code: 6789

imagemagick command to IMagick problem

Post by shirkavand »

Hi,

I am using(with some tweks) the next command to create a cilinder effect in a given image (found here http://www.imagemagick.org/Usage/mappin ... cement_map):

Code: Select all

convert testImage.jpg -background white -gravity south -splice 0x10 \
          \( +clone -sparse-color barycentric '0,0 black 319,0 white' \) \
          \( +clone -function arcsin 1 \) \
          \( -clone 1 -level 0%,100% \
                 -function polynomial -4,4,0 -gamma 2 \
                 +level 50%,0 \) \
          -delete 1 -swap 0,1  miff:- |\
     composite - -virtual-pixel white  -displace 0x10  testImage.jpg_cylinder.jpg

Now, i am trying to create the same command in IMagick, but with no luck yet, this is what i have so far:

Code: Select all

$image = new imagick( "girl.jpg" ); 
$firstImage = clone $image;
$firstImage->sparseColorImage(Imagick::SPARSECOLORMETHOD_BARYCENTRIC, array( 0, 0, Imagick::COLOR_BLACK, 319, 0, Imagick::COLOR_BLACK ));
$secondImage = clone $firstImage;
$secondImage->functionImage(Imagick::DISTORTION_ARC, array(1));
$thirdImage = clone $firstImage;
$thirdImage->levelImage(0.0, 1.0, 100.0);
$thirdImage->functionImage(Imagick::FUNCTION_POLYNOMIAL, array(-4, 4, 0));
$thirdImage->gammaImage(2.0);
$thirdImage->levelImage(50.0, 1.0, 0.0);
$firstImage->compositeImage($thirdImage, Imagick::VIRTUALPIXELMETHOD_WHITE, Imagick::COMPOSITE_DISPLACE, 0,10);
$firstImage->writeImages("./out.jpg" , false);
My fisrt problem is, i can not find "arcsin 1" equivalent in IMagick, so i used "DISTORTION_ARC", second i do not know if that set of commands are the correct ones to create the same result as the terminal command i am using. Third "SPARSECOLORMETHOD_BARYCENTRIC" seems to not be working fine, COLOR_WHITE does not exists... Any help will be very appreciated.

Regards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagemagick command to IMagick problem

Post by fmw42 »

Imagick has not kept up with ImageMagick enhancements. I doubt you will be able to overcome these issues. Imagick was not developed nor supported by the Imagemagick team. Perhaps you can get the Imagick developer to make some upgrade?

I suggest that you use PHP exec() to accomplish your goal.
shirkavand
Posts: 8
Joined: 2013-02-04T08:06:40-07:00
Authentication code: 6789

Re: imagemagick command to IMagick problem

Post by shirkavand »

Thanks for your help. Just wondering: using exec() has any performance issue over using a PHP shared library? R/ http://stackoverflow.com/questions/8264 ... function-t
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: imagemagick command to IMagick problem

Post by fmw42 »

shirkavand wrote:Thanks for your help. Just wondering: using exec() has any performance issue over using a PHP shared library? R/ http://stackoverflow.com/questions/8264 ... function-t
Perhaps, but for simple things, it does not seem to make much difference. See viewtopic.php?f=4&t=16779.

Also see sections on ImageMagick with PHP exec() and Imagick at http://www.rubblewebs.co.uk/index.php

I am told that using PerlMagick is quicker, but I have no experience, yet.
Post Reply