Search code examples
imagemagicktransparencytransparentalphaantialiasing

How do I avoid this ImageMagick anti-aliasing discoloration?


Update:

Thanks to a suggestion from paddy, it has come to my attention that the anti-aliasing looks fine on one of my machines, but not the other.


I'm trying to create a 24x24 png that features a filled shape with a transparent background. Here is the command I am working with:

convert -size 24x24 xc:none \
        -fill red \
        -draw "path 'M 0,0 L 24,0 A 24,24 0 0,0 0,24 Z' " result.png

"xc: _____" specifies a background color. (maybe this is where I'm mistaken?)

The output gives me the correct shape, but the border between the shape and the transparent area (i.e. the anti-aliased edge between color and transparency) is noticeably darkened:

ImageMagick expected vs. result

The anti-aliasing shown on the right is what I want from ImageMagick. Here's what I get for different values of xc:

Different ImageMagick xc values

As you can see, the anti-aliasing blends fine with solid colors, but not with transparency. The ImageMagick guide has a section on anti-aliasing and the problems it can cause, but reading through it, none of it's examples cover transparency. Any ideas?


Solution

  • Updating to a more recent version of ImageMagick/convert (6.9.1-6 Q16 i686 2015-06-30) fixed the problem for me. (Thanks, paddy)