2012-12-29

ImageMagick, making glyphs transparent

I've been installing the WikiHiero extension used in Wikipedia and because my webpage has a non-white background, and since the images of the hieroglyphs have a white background, it didn't look that good. So, I made some research for how to convert the images to transparent, and to make a grey-scale mask for smooth anti-aliased edges.

There are about 1,000 images in the map, but the execution went in a second or so, it's really quick. The first command creates the mask:

$ for file in hiero_*.png; do convert $file -negate mask_$file.png; done

Then apply the mask to the image:

$ for file in hiero_*.png; do convert $file -alpha Off \
> mask_$file.png -compose CopyOpacity -composite $file; done

That's it, now all images have a nice transparency:

No comments:

Post a Comment