Page 1 of 1

How to apply gradient color in png image using php ?

Posted: 2016-02-19T06:34:40-07:00
by king111
I want to apply gradient color Over PNG Image using PHP.
I want to apply the color in solid part only. Not to the transparent part.

Re: How to apply gradient color in png image using php ?

Posted: 2016-02-19T07:20:36-07:00
by fmw42
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See viewtopic.php?f=1&t=9620

Are you using PHP exec() or Imagick or another PHP API? Can you post an example input and output image to some place such as dropbox.com and put the URL here?

A guess at a process, might be to separate the alpha channel from the base image. Then composite together the base image, a constant color image and a gradient as a mask. Then add the alpha channel back to the composited image. There may be more efficient methods, also.

We need to know more before suggesting an exact command.

See
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/canvas/#gradient
http://www.imagemagick.org/Usage/canvas/#solid
http://www.imagemagick.org/Usage/masking/#alpha_extract
http://www.imagemagick.org/Usage/compose/#copyopacity