How to apply gradient color in png image using php ?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
king111
Posts: 2
Joined: 2016-02-19T06:30:23-07:00
Authentication code: 1151

How to apply gradient color in png image using php ?

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
Post Reply