I've got some images which have an alpha value of 240 where it should be fully opaque. Even the transparent areas should become more opaque.
For this i wanted to add 15 to the alpha channel of the whole image using convert.
I tried it with
convert --channel alpha -evaluate Add 15 +channel input.png output.png
But the alpha stays the same. If I use Multiply instead of Add it's possible to change the value with this command, but I want just Add 15 to every value.
Decrease Alpha with evaluate add doesn't work
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Decrease Alpha with evaluate add doesn't work
What does "convert -version" say? Probably that you are using Q16, where values go from 0 to 65535, not 0 to 255. So a 8-bit 240 becomes 240*256+240 = 61680, so you need to add 65535-61680 = 4335.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Decrease Alpha with evaluate add doesn't work
You can also add by percent. So compute 100*15/quantumrange where quantumrange is 255 for Q8 IM and 655535 for Q16 IM
or get percent from
convert xc: -format "%[fx:15*100/quantumrange]" info:
or get percent from
convert xc: -format "%[fx:15*100/quantumrange]" info:
Re: Decrease Alpha with evaluate add doesn't work
This is the output of the version command:
So I'm using Q16. When I add 4335 it works.
Code: Select all
Version: ImageMagick 6.7.7-10 2014-08-21 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP