hhh
hhh

Reputation: 52840

How to add Alpha -channels en masse with ImageMagick?

Suppose a dir with a lot of images, some of them miss the alpha-channel so looking bad against a background. I thought every picture had alpha -channel but some pictures now show white instead of having transparency. How can I add the alpha channels en masse?

Not Working

$ convert imageNoAlpha.png -alpha on imageAlpha.png

Upvotes: 2

Views: 3637

Answers (2)

hhh
hhh

Reputation: 52840

Thanks to Bonzo, I was able to get very cool results even without anti-alias! You can see the difference in the eyes with the below picture. I don't know how much you lose information by this but at least I am more able to adjust things, not so easy in anti-aliasing at least for me.

enter image description here

$ convert in.png -background none -fuzz 10% -transparent white -flatten out.png

En masse -approach is probably easiest with a bash -for-loop or use ImageMagick -pkg built for python. I don't know which approach is better, I will leave this here for future answers to improve. Thanks.

Upvotes: 0

Bonzo
Bonzo

Reputation: 5299

This will change white to transparent as in you coment BUT any other white in the image will be transparent as well:

convert input.jpg -background none -transparent white -flatten output.png

Upvotes: 3

Related Questions