Page 1 of 1

slight inconsistency converting alpha in txt: IM 6.4.3-6

Posted: 2008-09-04T16:11:08-07:00
by fmw42
IM 6.4.3-6 Q16 Mac OSX Tiger

This is not critical, but I just wanted to point it out. There seems to be a slight inconsistency in converting alpha values in the range 0-1 to 8-bit values relative how rgb values in range 0-100% are converted to 8-bit values.

For example:

convert -size 1x1 xc:"rgba(100%,75%,50%,0.5)" -depth 8 txt: | \
sed -n 's/ //g; s/^.*[^(]\((.*)\)[^)].*$/\1/p'
(255,191,127,128)

The rgb value of 50% goes to 127, but the alpha value of .5 goes to 128

On the other hand, the following is consistent due to the consistent use of floor()

convert -size 1x1 xc:"rgba(100%,75%,50%,0.5)" \
-format "(%[fx:floor(255*r)],%[fx:floor(255*g)],%[fx:floor(255*b)],%[fx:floor(255*a)])" info:
(255,191,127,127)

Re: slight inconsistency converting alpha in txt: IM 6.4.3-6

Posted: 2008-09-04T17:29:49-07:00
by magick
The TXT format looks like this:
  • 0,0: (255,191,127,128) #FFBF7F80 rgba(255,191,127,0.501961)
The values inside the rgba() container is RGB with alpha. Values in the first set of parenthesis is RGB with opacity. If alpha is 127, opacity is 255-alpha or 255-128 is 127 as expected.