Page 1 of 2
text is cut off after upgrade
Posted: 2013-07-06T09:15:33-07:00
by danieldan
Hi,
I was initially running Ubuntu 9.04 and whatever version of imagemagick was available at the time. I recently upgraded to ubuntu 12.04 and I also updated imagemagick to 6.8.5-4 (because the particular web application I'm using it with produces pixelated text in the output file [pdf] and I thought an upgrade might fix that). The text on the front end of the application is now being cut off on the right side. If someone could let me know how to determine which version I was running before so I can revert or (preferably) if someone could tell me how to fix the issue with the current version of imagemagick?
Here is an image of the issue:
- Text cut off on right side
- textcutoff.PNG (8.96 KiB) Viewed 6673 times
Here is the code to create the text:
Code: Select all
$width = 250;//$_POST[width];
$height = 100;//$_POST[height];
$name = rand().'.png';
$image = 'fonts/'.$name;
$w = $width + 100;
$h = $height + 100;
exec(IMAGEMAGICKPATH.' -trim -background transparent -depth 8 +antialias -font "'.$font.'" -fill #"'.$color.'" -size "'.$w.'"x"'.$h.'" label:"'.$text.'" "'.$image.'"');
exec(IMAGEMAGICKPATH.' "'.$image.'" -resize "'.$width.'"x"'.$height.'" -quality 100 "'.$image.'"');
Re: text is cut off after upgrade
Posted: 2013-07-06T09:19:25-07:00
by danieldan
Also, when I try to run the command manually on the server, I'm getting this error: convert: missing an image filename `-fill' @ error/convert.c/ConvertImageCommand/2949.
Above, it's supposed to say "Text Here". Some fonts are cut off more than others.
Re: text is cut off after upgrade
Posted: 2013-07-06T09:48:02-07:00
by fmw42
-trim +repage -depth 8
should come after creating the label:... image
There have been bugs with label: that have been fixed perhaps more recently (IM 6.8.5.7). See the changelog at
http://www.imagemagick.org/script/changelog.php
Also, when I try to run the command manually on the server, I'm getting this error: convert: missing an image filename `-fill' @ error/convert.c/ConvertImageCommand/2949.
What is the exact command line that you are running in the terminal without PHP?
I am not sure your quoting is proper for PHP. But I am not that much of an expert on that.
What is IMAGEMAGICKPATH? Is that a variable? Does it not need to be $IMAGEMAGICKPATH
I might write it more like
exec(" $IMAGEMAGICKPATH -background transparent -size ${w}x${h} +antialias -font $font -fill \"#$color\" label:\"$text\" -trim +repage -depth 8 $image ");
If you still have trouble with the text clipping, make the size larger than you need, since you are trimming anyway.
Re: text is cut off after upgrade
Posted: 2013-07-06T13:55:57-07:00
by danieldan
Here's the code I try to run manually on the server to test if it's working:
Code: Select all
/usr/bin/convert -trim -background transparent -depth 8 +antialias -font "/admin/fonts/ttf/1260211139645.ttf" -fill #"000000" -size "255x299" label:"Text Here" "/fonts/123.png"
/usr/bin/convert "fonts/123.png" -resize "155x199" -quality 100 "fonts/123.png"
IMAGEMAGICKPATH is just a variable holding the current location of "convert" on the server. /usr/bin/convert in other words.
Thank you for the quick reply. I'm quite new to imagemagick/php/webdev. Someone else built this web app and I'm trying to maintain it.
Re: text is cut off after upgrade
Posted: 2013-07-06T14:55:10-07:00
by fmw42
Note your quote on the hex color may be incorrect. try
/usr/bin/convert -background transparent +antialias -font "/admin/fonts/ttf/1260211139645.ttf" -fill "#000000" -size "255x299" label:"Text Here" -trim +repage -depth 8 "/fonts/123.png"
/usr/bin/convert "fonts/123.png" -resize "155x199" -quality 100 "fonts/123.png"
Note as long as there are no spaces or other odd characters in the path and filenames, those quotes are unnecessary.
If these do not work, then be sure you have write permission for the fonts/ directory and read permissions for admin/ directory.
Also try
type -a convert
to verify that im convert is at /usr/bin and not /usr/local/bin
Also try
/usr/bin/convert -version
to be sure your IM is at /usr/bin and working.
Re: text is cut off after upgrade
Posted: 2013-07-06T15:39:43-07:00
by danieldan
Good catch on the hex color quote. I ran what you had and received some different errors (a lot of the following):
convert: delegate library support not built-in `/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1452.
convert: unable to read font `/admin/fonts/ttf/1260211139645.ttf' @ warning/annotate.c/RenderType/810.
convert: delegate library support not built-in `/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1452.
convert: no encode delegate for this image format `/fonts/123.png' @ error/constitute.c/WriteImage/1180.
running type -a convert came back with:
:~$ type -a convert
convert is /usr/local/bin/convert
convert is /usr/bin/convert
/usr/bin/convert -version returns:
Version: ImageMagick 6.6.5-5 2010-11-05 Q16
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP
Which is different than what convert --version returns:
Version: ImageMagick 6.8.5-4 2013-05-03 Q16
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib djvu fontconfig freetype jng jp2 jpeg lcms lqr openexr pango png ps tiff x xml zlib
This explains why it's throwing the delagate error even though I thought I'd fixed that. At least it seems like a step towards progress. Seems like you were right about convert pointing to the wrong version and probably the permissions on the directory. How do I fix this?
Thank you for the help. I appreciate it. If I get this going, I will send you a free shirt of your choice.
Re: text is cut off after upgrade
Posted: 2013-07-06T15:43:06-07:00
by fmw42
It would seem that convert is /usr/local/bin/convert is running newer code. check
/usr/local/bin/convert -version
and see if it is the same as
convert -version
You can then either just use convert or if PHP objects then use /usr/local/bin/convert
See if that works before worrying about permissions.
Be sure that the version of convert you use has freetype delegate installed and shows when you run ...convert -version
To check what delegates you have on the older version run
/usr/bin/convert -list configure
then look at the line starting with DELEGATES.
The newer versions of IM should show the delegates now with ...convert -version
Re: text is cut off after upgrade
Posted: 2013-07-06T16:07:29-07:00
by danieldan
So, I got it to work manually with the following line:
Code: Select all
:~$ sudo /usr/local/bin/convert -background transparent +antialias -font "/site/admin/fonts/ttf/1260211139645.ttf" -fill "#000000" -size "350x200" label:"Text Here" -trim +repage -depth 8 "/site/admin/fonts/123.png"
However, I still have the issue of the text being cut off on the right side of the image. Also, the text seems pixelated when I view it with the current size settings.
Re: text is cut off after upgrade
Posted: 2013-07-06T16:22:03-07:00
by snibgo
"Pixellated" -- does removing "+antialias" give what you want?
Re: text is cut off after upgrade
Posted: 2013-07-06T16:35:36-07:00
by danieldan
Code: Select all
~$ /usr/bin/convert -list configure
Shows no delegates listed. The version for this one is 6.6.5
Re: text is cut off after upgrade
Posted: 2013-07-06T16:47:34-07:00
by danieldan
results
123.png
123antialias.png
The only difference is removing the +antialias from the command.
Re: text is cut off after upgrade
Posted: 2013-07-06T17:00:08-07:00
by fmw42
What do you get if you only use the width or the height but not both?
-size Wx or -size xH
does it still clip?
Some fonts have messed up metrics and that could be the cause. But there was a patch to label: in the changelog
2013-05-11 6.8.5-7 Cristy <quetzlzacatenango@image...>
Labels no longer overflow (reference
viewtopic.php?f=3&t=22964).
Re: text is cut off after upgrade
Posted: 2013-07-06T17:11:49-07:00
by fmw42
Something is very wrong if you get such different sizes by just removing +antialias
Re: text is cut off after upgrade
Posted: 2013-07-06T17:23:16-07:00
by danieldan
So, that seemed to do the trick. I think the text looks better with antialias turned off. I hope that fixes the pixelization in the final output file as well. Now I just need to change the php file and see if it works. I will pm you with a coupon code you can use for a free shirt. Thank you for your help.
Re: text is cut off after upgrade
Posted: 2013-07-27T17:13:39-07:00
by danieldan
Here's the next line I need to troubleshoot. I think this is where the pixelation is coming from for the final output file:
Code: Select all
exec(IMAGEMAGICKPATH.' "'.$image.'" -resize "'.$width.'"x"'.$height.'" -quality 100 "'.$image.'"');
Do I just remove the height specification? That would be my guess.
Fred, check your pm for a coupon code for a free shirt. I appreciate your help. Though you'll have to wait until I get this output file issue fixed before you can order.