Decrease Alpha with evaluate add doesn't work

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
Maniac
Posts: 3
Joined: 2015-01-14T12:06:58-07:00
Authentication code: 6789

Decrease Alpha with evaluate add doesn't work

Post by Maniac »

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.
snibgo
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

Post by snibgo »

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
User avatar
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

Post by fmw42 »

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:
Maniac
Posts: 3
Joined: 2015-01-14T12:06:58-07:00
Authentication code: 6789

Re: Decrease Alpha with evaluate add doesn't work

Post by Maniac »

This is the output of the version command:

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
So I'm using Q16. When I add 4335 it works.
Post Reply