Trying to generate crisp text (se examples)

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
zlitrox

Trying to generate crisp text (se examples)

Post by zlitrox »

Hello,

I'm using ImageMagick (ImageMagick 6.6.2-5) and trying to generate sort of crisp text. Se below for example images.

My goal is to have the text look like this (created with Photoshop):
Image (http://d0h.us/example_photoshop.png)
And having the result (created with ImageMagick):
Image (http://d0h.us/example_imagemagick.png)
convert -antialias -background transparent -fill '#000000' -font Arial -pointsize 12 label:'name@domain.com'

If i try without antialias it seems to miss some pixels:
Image (http://d0h.us/example_imagemagick_noaa.png)
convert +antialias -background transparent -fill '#000000' -font Arial -pointsize 12 label:'name@domain.com'

So what i want is the text to look like the one that were created in Photoshop. Can someone please help me?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Trying to generate crisp text (se examples)

Post by fmw42 »

try adding -strokewidth 0 and see if that helps (not sure if that works with label:), but you could try using either -annotate or -draw and see if they do what you want.

see http://www.imagemagick.org/Usage/text/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Trying to generate crisp text (se examples)

Post by anthony »

-strokewidth will not do anything (except posible minor size effect) without -stroke {color} also being set.

stroke values below 1 do not seem to work very well, but may work in this case.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
zlitrox

Re: Trying to generate crisp text (se examples)

Post by zlitrox »

fmw42 wrote:try adding -strokewidth 0 and see if that helps (not sure if that works with label:), but you could try using either -annotate or -draw and see if they do what you want.

see http://www.imagemagick.org/Usage/text/
Thanks for the tip, but unfortunately "-strokewidth 0" didnt do any change to the text even with or without "-stroke #000000". Also i've tried -draw but didnt work with that.

I thought that maybe it could be "-style", "-weight" or "-stretch" but when i looked fast at them it didnt do any change. Maybe i'm doing something wrong...


Do you guys have any other tip?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Trying to generate crisp text (se examples)

Post by el_supremo »

This produces an image that looks identical to the photoshop version (using IM 6.6.5-8 2010-11-10 Q16 on Win 7 Pro x64):

Code: Select all

convert +antialias -background transparent -fill '#000000' -font Arial -pointsize 12 -strokewidth 1 label:'name@domain.com' label.png
[EDIT] ERK - no it doesn't. There's a few bits missing. I'll play with it some more.[/EDIT]
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Trying to generate crisp text (se examples)

Post by fmw42 »

Is it possible that PS and IM are using two different fonts, even if named the same? Perhaps PS has its own imbedded fonts? Or they are the same named fonts but slightly different versions and are in different directories.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Trying to generate crisp text (se examples)

Post by anthony »

I think the real difference is in the selection of the font.

You can get fonts that are designed to be a 'bitmap' when drawn. That is no anti-aliasing pixels included.

It really depends on what you mean by 'crisp'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
zlitrox

Re: Trying to generate crisp text (se examples)

Post by zlitrox »

anthony wrote:I think the real difference is in the selection of the font.

You can get fonts that are designed to be a 'bitmap' when drawn. That is no anti-aliasing pixels included.

It really depends on what you mean by 'crisp'.
Oh ok, so photoshop uses a different font than i use on my imagemagick server?

What i tried to show with crisp is that a generated image should look more like html-text if you know what i mean. The text in html are not like smooth as sIFR text or any text created with antialias. Maybe its just the thickness of the generated text that makes my images look different...
zlitrox

Re: Trying to generate crisp text (se examples)

Post by zlitrox »

el_supremo wrote:This produces an image that looks identical to the photoshop version (using IM 6.6.5-8 2010-11-10 Q16 on Win 7 Pro x64):

Code: Select all

convert +antialias -background transparent -fill '#000000' -font Arial -pointsize 12 -strokewidth 1 label:'name@domain.com' label.png
[EDIT] ERK - no it doesn't. There's a few bits missing. I'll play with it some more.[/EDIT]
Pete
Thank you, let me know if you do any success :)
zlitrox

Re: Trying to generate crisp text (se examples)

Post by zlitrox »

fmw42 wrote:Is it possible that PS and IM are using two different fonts, even if named the same? Perhaps PS has its own imbedded fonts? Or they are the same named fonts but slightly different versions and are in different directories.
I'm using TrueType-font with full specified path then generating ImageMagick image. But that could be a possible problem, i'll try to copy the font that PS is using to my server that generates ImageMagick image and see if it works.

Thank you for your suggestion.
zlitrox

Re: Trying to generate crisp text (se examples)

Post by zlitrox »

fmw42 wrote:Is it possible that PS and IM are using two different fonts, even if named the same? Perhaps PS has its own imbedded fonts? Or they are the same named fonts but slightly different versions and are in different directories.
I copied the font that Photoshop uses to the server that generates ImageMagick images but the same thing. Looks like the examples i included in my first post.

Any other ideas?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Trying to generate crisp text (se examples)

Post by anthony »

As the TTF font file is the same, the difference will be down to the way the font is 'rendered' or drawn onto a raster image.

ImageMagick calls on a separate library, freetype, to do this. It basically passes the text and the parameters to this library and gets back a raster image, and actually does not have control of how the font is rendered.

Different versions of that library have resulted in different results. Maybe you can upgrade that library.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply