Font Spacing Problem between Photoshop and ImageMagick

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
debakar

Font Spacing Problem between Photoshop and ImageMagick

Post by debakar »

Hello Experts,

I am baffled with font spacing problem between photoshop and imagemagick. I am trying to explain the problem below:

1. I open Photoshop, create a new file, white background, 72dpi RGB.
2. I choose "Impact" font, 70pt, Sharp. All other character settings are default (such as Auto, 0, 100% etc).
3. I write the text "Engaging" using the text tool.

Now, I use imagemagick to generate the same text using the following command:

Code: Select all

convert -depth 8 -density 72 -background transparent -fill red -font './impact.ttf' -pointsize 70 label:'Engaging' text_test.png
Note that I have copied the impact.ttf font from my C:\Windows\Fonts directory to the folder where I am executing the convert command. So both Photoshop and ImageMagick are using the same font file.

Next, I open the text_test.png file in Photoshop, copy all, paste it on my previous file as a new layer. What I see is, the height of the characters are perfectly fine, but the width of text generated from ImageMagick is less than that in photoshop. I am not sure if the spacing is less or width of each character, but somehow the text generated with ImageMagick does not match that in photoshop.

Here is a screenshot of the above problem to help understand the problem:

Image

Can anyone guide me if I am doing anything wrong? Any help will be highly appreciated.

Thank You.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Font Spacing Problem between Photoshop and ImageMagick

Post by fmw42 »

Change the kerning value in IM. http://www.imagemagick.org/script/comma ... hp#kerning

Perhaps IM and PS have different defaults.
debakar

Re: Font Spacing Problem between Photoshop and ImageMagick

Post by debakar »

This is not an option. We are developing a flash tool to create a design letterhead and then generating the same on server using ImageMagick. We have successfully done all but the text rendering due to this problem. User can choose any font in his design. I posted this topic using Impact font because the difference appears to be maximum with this font. I cannot keep on experimenting with what kerning value will be required for which font.

My question is, even if everything is default in both Photoshop & ImageMagick, why would the text differ so much? Even flash displays the font in same size as does Photoshop. Comparing a screenshot taken from the flash tool and text drawn in Photoshop shows absolutely no difference, but the same generated with ImageMagick has an appreciable difference. And the fun part is, the difference is different depending on which font is used. Impact font was selected for my post to explain the problem.
debakar

Re: Font Spacing Problem between Photoshop and ImageMagick

Post by debakar »

Hello everyone there,

Can anyone throw some light on this problem? I am eagerly waiting for a direction.
Thanks.
DK
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Font Spacing Problem between Photoshop and ImageMagick

Post by anthony »

The problem is with the rendering engine, not with ImageMagick.

ImageMagick calls a external library "freetype" to do the font drawing. As such the issue will need to be taken up with the developers of that library.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
debakar

Re: Font Spacing Problem between Photoshop and ImageMagick

Post by debakar »

I upgraded freetype and freetype-devel to version 2.2.1-21.el5_3 through yum.

Code: Select all

yum update freetype
A test after that did not show any change. I then went ahead and updated ImageMagick to ImageMagick-6.6.3-2 (the installed version was ImageMagick-6.6.2-9). After that it all worked fine. Now the same test done above in the start of this post shows negligible difference in the text in Photoshop and generated through IM.

Thank you very much for the direction.
Post Reply