Text on Transparent background

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
chnet

Text on Transparent background

Post by chnet »

I'm simply trying to draw white text onto a transparent background and save it as a transparent PNG but it's not working as expected. Instead of being pure white and semi-transparent, it has black artifacts, as if the text was written on black, and then cut out.

My Command:

Code: Select all

convert -size 203x29 xc:none -font ACaslonPro-Semibold.otf -pointsize 15 -draw " fill "#FFFFFF" text 26,19 'Home'" output.png
If you look at the examples below, you can see that when I draw the text over a black background (fig. C), it looks nice and smooth. But if I draw it over a transparent background, it comes out jagged (fig A. and B). The root of the problem appears to me when you place the transparent image over a white background with photoshop (fig. D). You can see, rather than semi-transparent WHITE edges, it has semi-transparent BLACK edges.

What am I doing wrong?

Examples of what is happening:
Image
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Text on Transparent background

Post by el_supremo »

Your text is probably being antialiased. Add the option +antialias before the -font option.

Pete
chnet

Re: Text on Transparent background

Post by chnet »

Well I would like to have the antialias on so the font is smooth.

Is there a way to do this with it still on?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Text on Transparent background

Post by anthony »

You are experiencing the very OLD text halo bug...
Which was fix for text, resize and blur around IM v6.2.4

Also watch you quoting... You are unquoting the fill color within the drawing command!


I suggest you upgrade ASAP!

Note you are also missing out on cool updates for GIF animation handling, Order Dither, and most recently Image Distortion. That latter will also have a MAJOR improvement in output results very soon, as I am just finialising the programing of
Elliptical Weighted Re-sampling methods.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
chnet

Re: Text on Transparent background

Post by chnet »

Anthony, thanks for your response.

I am using Imagemagick 6.3.5 or at least thats what it tells me when I enter the command:

Code: Select all

convert -version
which outputs:
Version: ImageMagick 6.3.5 08/23/07 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC

Any ideas what could be the problem?
chnet

Re: Text on Transparent background

Post by chnet »

ah ha, it seems my server has two installations, php was using one that was 5.4

So I think that'll fix it after I sort that problem out.

Thanks!!!
Post Reply