Page 1 of 1

imagemagick command to IMagick problem

Posted: 2013-02-06T13:43:18-07:00
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

Re: imagemagick command to IMagick problem

Posted: 2013-02-06T15:54:40-07:00
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.

Re: imagemagick command to IMagick problem

Posted: 2013-02-06T16:01:09-07:00
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

Re: imagemagick command to IMagick problem

Posted: 2013-02-06T19:09:55-07:00
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.