convert white shades in grayscale image transparent

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
ravikum
Posts: 34
Joined: 2013-03-20T05:35:37-07:00
Authentication code: 6789

convert white shades in grayscale image transparent

Post by ravikum »

Hi,
I have a grayscale passport size photo of a person.
How to convert all the white shades in that transparent, and keep the black color not transparent.

I have tried the command

Code: Select all

convert 1.png -background black -alpha copy -type truecolormatte PNG32:1_alpha.png
from this page viewtopic.php?f=1&t=17526#p65952
but it seems to do the opposite.

Please help.
Thanks
(using the latest IM version on linux centos 6)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert white shades in grayscale image transparent

Post by fmw42 »

This request is not really very clear.

Is your image black and white or gray? Do you want to preserve the pure black and make the rest of the grays transparent or do you want to make pure white transparent and leave the rest as is?

Perhaps you should post your image to some free hosting service such as dropbox.com and put the URL here.

This works fine for me on IM 6.8.9.7 Q16 Mac OSX with a grayscale image.

Code: Select all

convert image.png -alpha copy PNG32:result.png
ravikum
Posts: 34
Joined: 2013-03-20T05:35:37-07:00
Authentication code: 6789

Re: convert white shades in grayscale image transparent

Post by ravikum »

Thanks.
The code above is working for me.
(using the latest IM version on linux centos 6)
Post Reply