How to convert a PNG with full transparency into 50% 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
xberg
Posts: 13
Joined: 2017-11-23T03:02:10-07:00
Authentication code: 1152

How to convert a PNG with full transparency into 50% transparent?

Post by xberg »

Hi,

The PNG has some areas completely transparent and other areas fully opaque. I only want to have the opaque areas 50% transparent while keeping full transparency in the areas which are already fully transparent.

This is what I do:

Code: Select all

magick in.png -alpha set -channel A -evaluate set 50% +channel out.png
However this fills the areas that are 100% transparent with 50% opacity which is not what I want.
xberg
Posts: 13
Joined: 2017-11-23T03:02:10-07:00
Authentication code: 1152

Re: How to convert a PNG with full transparency into 50% transparent?

Post by xberg »

OK, I found the solution: use multiply:

magick convert 1.jpg -alpha set -channel A -evaluate multiply 0.50 +channel logo-just-transparent50pc-alpha.png
Post Reply