Page 1 of 1

Help:Strange Things when disable Alpha

Posted: 2010-10-26T12:03:03-07:00
by Axolotl
Hi i'm Newbie.
I have such a problem. When i resize image with transparent alpha background with IM, and then trying to disable alpha channel "-Alpha off" or just write to bmp using BM3: some huge multicoloured halo appears over the image, not the semi-transparent pixels after antialiasing, but much more. This Happens not matters if i use before disabling alpha "-alpha -threshold" or not.
Here before "-alpha off"
Image
and here After
Image

what i do wrong?

Re: Help:Strange Things when disable Alpha

Posted: 2010-10-26T12:58:01-07:00
by fmw42
your alpha channel is not binary and is trimming some of the white areas or making them partially transparent against the black background.

You can see that by alternating views between the original, image with out alpha and image of alpha channel

to get the latter two

convert 81362956.png -alpha off 81362956_aoff.png
convert 81362956.png -alpha extract 81362956_alpha.png

Re: Help:Strange Things when disable Alpha

Posted: 2010-10-26T13:33:37-07:00
by Axolotl
Yeah, thanks for tip. The solution is to use "-alpha background" before "-alpha off"

Re: Help:Strange Things when disable Alpha

Posted: 2010-10-27T00:02:28-07:00
by anthony
Alpha background only sets the color of pixels which are fully transparent. It does not effect the color of semi-transparent pixels, whcih is the color you see when you true off alpha.

The BEST way to handle this if to overlay the image onto a background of the right color.
and there are two method in IM that are commonly used for this purpose.

The first is to 'flatten' the image onto a background...

Code: Select all

    -background {color} -flatten -alpha off
This is the most common method the whole technique has become known as 'flattening' images, though really it is more a 'set image background' operation. however it only works for one image, as the operators real task is to 'flatten' multiple images into a single image.

The other common method will work for a sequence of images, and will leave the images separate, but with the transparency replaced by the boarder color.

Code: Select all

   -bordercolor {color} -border 0 -alpha off
Other operators can also do this too, but the operators 'normal' actions more often than not gets in the way. These operators include... -mosaic, -layers merge, -frame, -coalease.

However what you are really trying to do (in full) is..

Code: Select all

    ....  \( +clone -alpha opaque -fill {color} -colorize 100% \) \
          +swap -geometry +0+0 -compose Over -composite -alpha off ....
The above has now been collected together in IM examples, Basics,
Removing Alpha transparency
http://www.imagemagick.org/Usage/basics/#alpha_remove

This section now replaces all the other sections and bits around IM Examples that previously looked at or discussed removing alpha channel, Such as
JPEG Transparency - NOT
http://www.imagemagick.org/Usage/format/#jpg_trans

Re: Help:Strange Things when disable Alpha

Posted: 2010-10-27T11:23:02-07:00
by amar_nishant
Try
-alpha on or -alpha set
-background none