Page 1 of 1

How do I convert a JPG into a 50% transparent PNG?

Posted: 2017-12-22T01:23:59-07:00
by xberg
Hi,

I want to transform any JPG into a 50% transparent PNG.
I found how to make a specific color fully transparent with:

Code: Select all

magick convert 1.jpg -fuzz 8%% -transparent white 1.png
But I don't want this: I want all the JPG to be a 50% opaque PNG.

Thanks

Re: How do I convert a JPG into a 50% transparent PNG?

Posted: 2017-12-22T01:44:11-07:00
by snibgo

Code: Select all

magick in.jpg -alpha set -channel A -evaluate set 50% +channel out.png

Re: How do I convert a JPG into a 50% transparent PNG?

Posted: 2017-12-22T01:47:17-07:00
by xberg
Thank you!
Great!! What's the +channel at the end for?

Re: How do I convert a JPG into a 50% transparent PNG?

Posted: 2017-12-22T02:05:53-07:00
by snibgo
"-channel A" means "apply all following operations to just the Alpha channel". "+channel" means "set the default, which is that all following operations apply to all channels".

In this case it is superfluous, but good practice is: whenever you have a "-channel", you should always have a "+channel" somewhere.

Re: How do I convert a JPG into a 50% transparent PNG?

Posted: 2017-12-22T02:18:17-07:00
by xberg
Thanks! Great explanations :)