Page 1 of 1
Equivalent of ImageMagick gradient for php Imagick
Posted: 2017-04-20T11:02:21-07:00
by Defacta
Hello,
I looked for the equivalent of
gradient for Imagick at
http://php.net/manual/en/class.imagickpixel.php and at
http://php.net/manual/en/class.imagick.php with no success.
What is the equivalent of
Code: Select all
convert -size 128x128 gradient:"rgba(255,0,0,0)-rgba(255,0,0,1)" 1.png
for php Imagick?
And at a general level, how to find the equivalent of an ImageMagick feature for php Imagick?
Many thanks.
Re: Equivalent of ImageMagick gradient for php Imagick
Posted: 2017-04-20T11:22:14-07:00
by snibgo
As the question is about IMagick, I'm moving it to the IMagick forum.
A search for "gradient" in the IMagick forum shows answers, such as
viewtopic.php?f=18&t=29903&p=134571&hil ... nt#p134571
Re: Equivalent of ImageMagick gradient for php Imagick
Posted: 2017-04-20T11:40:10-07:00
by Defacta
Oh, ok thanks.
It's working for:
Code: Select all
$imgLine->newPseudoImage(500, 500, 'gradient:#cbcbcb-#94938f');
But not for:
Code: Select all
$imgLine->newPseudoImage(500, 500, 'gradient:direction=east gradient:#cbcbcb-#94938f');
Same code with direction from
https://www.imagemagick.org/script/gradient.php
I get the error message:
Uncaught exception 'ImagickException' with message 'unrecognized color `direction=east gradient:#cbcbcb'
So tried also "gradient:angle=90 gradient: #cbcbcb-#94938f" but with the same error message. Any idea how to make a gradient with a specific direction ?
Thanks,
Vincent.
My version of Imagick :
imagick module version 3.2.0RC1
And:
convert -version
Version: ImageMagick 6.9.3-10 Q16 x86 2016-05-04
http://www.imagemagick.org
Re: Equivalent of ImageMagick gradient for php Imagick
Posted: 2017-04-20T11:52:08-07:00
by snibgo
At the command line, "gradient:direction" etc need "-define". I don't know the equivalent in IMagick.
Re: Equivalent of ImageMagick gradient for php Imagick
Posted: 2017-04-20T11:55:24-07:00
by Bonzo
The angled gradient is probably not supported In Imagick - it only supports some of the imagemagick operators and options.
I would create the gradient image and then rotate it or use exec( ) with the command you have.
Re: Equivalent of ImageMagick gradient for php Imagick
Posted: 2017-04-20T12:34:27-07:00
by Defacta
Yes, by rotating it. Thanks for the help