Page 1 of 1

Set Opacity, but retain transparent sections in image?

Posted: 2018-08-09T02:12:51-07:00
by radiohead
Version ImageMagick-7.0.8-Q16

I'm a Newbie, but have read and trying to comply with the board guidelines!

I have a pile of png's which have a coloured area upon a (fully) transparent background. I am trying to set the opacity of the coloured area so it is semi-transparent, but retain the transparent area as fully transparent.

I have tried this:
FOR %G IN (*.png) DO convert %G -alpha set on -channel a -evaluate set 68% batch\%G

It sets the Opacity correctly, BUT it also makes the transparent area opaque - you can see the problem most obviously when it is overlaid in a Google map like this: http://a-bc.co.uk/MCA/AL000288-SK11350032.html:

Does anyone have any ideas how to get this right? To recap I want an image like you see on the above website link, but the hazy white area needs to be totally transparent, but the green and yellow areas semi-opaque.

I don't mind if it has to be done in 2 or more stages - the main thing is that I don't have to manually do it on 2000 images!

Re: Set Opacity, but retain transparent sections in image?

Posted: 2018-08-09T05:58:53-07:00
by snibgo
radiohead wrote:-evaluate set 68%
This sets all the alpha values to 68%, whatever they were before. Instead, you can multiply them, eg to 0.68 times what they were before.

"-alpha" can't take two parameters. Use "set" or "on", but not both. Or do "-alpha set -alpha on" if you want to do both.

When you have "-channel X", I suggest you always have a "+channel" after the operations you want restricted to that channel.

So:

Code: Select all

FOR %G IN (*.png) DO convert %G -alpha set -channel a -evaluate multiply 0.68 +channel batch\%G

Re: Set Opacity, but retain transparent sections in image?

Posted: 2018-08-09T07:23:29-07:00
by radiohead
Genius!

I have no idea what most of that means - but it works which is all that matters at the moment! In slow time I'll try and read, digest and learn from your explanation.

A million thanks - well actually about 2000 thanks!