Re: Convert grayscale image to black plus transparency?
Posted: 2012-08-22T12:20:05-07:00
So this should be what is wanted:
convert sample-gray.jpeg -set colorspace gray \
\( -clone 0 -fill black -colorize 100% \) \
\( -clone 0 -negate \) \
-delete 0 -alpha off -compose copy_opacity -composite PNG32:sample_gray_correct.png
This also works and is shorter:
convert sample-gray.jpeg -set colorspace gray \
-negate -background black -alpha shape -background black -alpha background \
PNG32:sample_gray_correct2.png
see
http://www.imagemagick.org/Usage/masking/#alpha_shape
http://www.imagemagick.org/Usage/maskin ... background
convert sample-gray.jpeg -set colorspace gray \
\( -clone 0 -fill black -colorize 100% \) \
\( -clone 0 -negate \) \
-delete 0 -alpha off -compose copy_opacity -composite PNG32:sample_gray_correct.png
This also works and is shorter:
convert sample-gray.jpeg -set colorspace gray \
-negate -background black -alpha shape -background black -alpha background \
PNG32:sample_gray_correct2.png
see
http://www.imagemagick.org/Usage/masking/#alpha_shape
http://www.imagemagick.org/Usage/maskin ... background