Page 1 of 1

Multiple opacities in an image

Posted: 2018-09-26T09:37:14-07:00
by adamrobbins2018
I have a black-and-white image where want to add transparency.
I need multiple transparency levels according to the grey level of each pixel. If a pixel is close to black, it must be opaque (less transparent). If grey, medium transparent, and if white, almost 100% transparent.Is there a way to do this? Does a .png format even support such multiple transparencies?
Thanks for your help in advance.

Re: Multiple opacities in an image

Posted: 2018-09-26T09:53:57-07:00
by fmw42
Yes, PNG supports 8-bit transparency. The command should be

Code: Select all

convert image.png -alpha copy image.png
see
https://imagemagick.org/Usage/masking/#alpha_copy


If that does not work. Then in Unix

Code: Select all

convert image.png \( +clone \) -alpha off -compose copy_opacity -composite image.png
For Windows,

Code: Select all

convert image.png ( +clone ) -alpha off -compose copy_opacity -composite image.png
_____________________

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 the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown