Page 1 of 1

ImageMagick Strange size/text issue

Posted: 2019-01-21T08:29:03-07:00
by TonyMonstar
Hi,

Not sure if this is the right category for the following.

I have ImageMagick Installed on two different centos versions Centos 5.11,Centos 6, the version of image magick is the same on both 6.7.2, for centos 5 I had to compile the source to get the same version installed.

The issue i'm getting is when converting a pdf to png and applying text on the converted png I get a different output on the centos 5.11, the png is very small and the text that was placed using -draw (text) is disfigured.

Process of what i'm doing

Code: Select all

1 ) I first convert the pdf page to png 
convert -density 288 pdfdoc.pdf pdfimage.png
2)I then apply the text to the image and create a new png file
convert -pointsize ${array[1]} -fill ${array[2]} -draw "text ${array[3]},${array[4]} '${array[0]}' " -font "${array[5]}" $TMP/pdfimage.png $TMP/finalpdfimage.png
Image of text on centos 5.11:
Image
https://imgur.com/a/6Lnp0Qa

Image of text on centos 6:
Image
https://imgur.com/a/vuNuisX


Many thanks
Tony.

Re: ImageMagick Strange size/text issue

Posted: 2019-01-21T08:36:41-07:00
by snibgo
You are reading a PDF, so IM delegates that work to Ghostscript. I suspect you are using two different versions of GS. They may also be old. IM v6.7.2 is certainly old. I suggest you upgrade.

Re: ImageMagick Strange size/text issue

Posted: 2019-01-21T09:02:02-07:00
by TonyMonstar
snibgo wrote: 2019-01-21T08:36:41-07:00 You are reading a PDF, so IM delegates that work to Ghostscript. I suspect you are using two different versions of GS. They may also be old. IM v6.7.2 is certainly old. I suggest you upgrade.
Just checked the version of ghostscript and i'm using 8.70 on both centos versions, I think the issue is not the pdf to image conversion but when adding text to the png step two in my process.

Re: ImageMagick Strange size/text issue

Posted: 2019-01-21T09:11:39-07:00
by snibgo
I'll move this to the "Users" forum.

I suggest you upgrade to current v6 ImageMagick, and a more recent Ghostscript eg v9.19. Also rearrange the command so you read the PDF, then draw text on it, then write the output.

If you still have problems, please say exactly what command is used, ie without variables like ${array[1]}, and supply all the input files.

Re: ImageMagick Strange size/text issue

Posted: 2019-01-23T07:29:18-07:00
by TonyMonstar
snibgo wrote: 2019-01-21T09:11:39-07:00 I'll move this to the "Users" forum.

I suggest you upgrade to current v6 ImageMagick, and a more recent Ghostscript eg v9.19. Also rearrange the command so you read the PDF, then draw text on it, then write the output.

If you still have problems, please say exactly what command is used, ie without variables like ${array[1]}, and supply all the input files.
Many thanks.

I have run some more tests without my script.

Commands:
1)

Code: Select all

convert -density 150 testpdf.pdf testimage1centos5.png
2)

Code: Select all

convert -pointsize 30 -fill "Black" -draw "text 173,1341 '09-01-2019'" -font "Courier" testimage1centos5.png testimage2centos5.png
Output image Centos 5: https://imgur.com/a/3QgTGDA

Output image Centos 6: https://imgur.com/a/FWJ1p4I

As you can see the text (date) that was placed using centos 5 is all pushed together, the pdf and commands run are exactly the same on both versions of the os.

Re: ImageMagick Strange size/text issue

Posted: 2019-01-23T10:51:55-07:00
by fmw42
The question was what are your versions of Ghostscript that Imagemagick uses to render the PDF files. If they are not the same and current, then upgrade them to the same versions. With regard to the text, what are your versions of freetype delegate used by Imagemagick. If they are not the same and current then upgrade to the same versions. Also be sure you upgrade your Imagemagick to the most current version that you can (by date and not by version number). Linux patches Imagemagick often without changing the version number.

Re: ImageMagick Strange size/text issue

Posted: 2019-01-24T15:25:41-07:00
by TonyMonstar
fmw42 wrote: 2019-01-23T10:51:55-07:00 The question was what are your versions of Ghostscript that Imagemagick uses to render the PDF files. If they are not the same and current, then upgrade them to the same versions. With regard to the text, what are your versions of freetype delegate used by Imagemagick. If they are not the same and current then upgrade to the same versions. Also be sure you upgrade your Imagemagick to the most current version that you can (by date and not by version number). Linux patches Imagemagick often without changing the version number.
Just updated the freetype deligates and the problem still remains.
GhostScript is also updated.
Now i'm trying to compile the latest version of imagemagick on centos 5 to get it updated, and i'm getting the following error after compiling.

Code: Select all

make  all-am
make[1]: Entering directory `/home/imagemagick7/ImageMagick-7.0.8-24'
  CCLD     utilities/magick
MagickCore/.libs/libMagickCore-7.Q16HDRI.so: undefined reference to `FcConfigSetRescanInterval'
collect2: ld returned 1 exit status
make[1]: *** [utilities/magick] Error 1
make[1]: Leaving directory `/home/imagemagick7/ImageMagick-7.0.8-24'
make: *** [all] Error 2

Re: ImageMagick Strange size/text issue

Posted: 2019-01-24T16:25:08-07:00
by fmw42
I do not know Linux installs. But did you follow the instructions and download from https://imagemagick.org/script/download.php.

Did you get and install ImageMagick-libs --- ImageMagick-libs-7.0.8-24.x86_64.rpm --- as well as ImageMagick-7.0.8-24.x86_64.rpm

Re: ImageMagick Strange size/text issue

Posted: 2019-01-25T05:48:34-07:00
by TonyMonstar
fmw42 wrote: 2019-01-24T16:25:08-07:00 I do not know Linux installs. But did you follow the instructions and download from https://imagemagick.org/script/download.php.

Did you get and install ImageMagick-libs --- ImageMagick-libs-7.0.8-24.x86_64.rpm --- as well as ImageMagick-7.0.8-24.x86_64.rpm
Will these rpm's work on centos 5? I thought to get it installed on centos 5 you need to compile the sourcecode, I could be wrong.

Re: ImageMagick Strange size/text issue

Posted: 2019-01-25T10:31:16-07:00
by fmw42
You may be correct. The binaries listed are for CentOS 7. You can try with CentOS 5. Unfortunately, I do not know Linux installs.