Page 1 of 1

Problems with image to PDF conversion

Posted: 2011-06-05T08:32:25-07:00
by squirrel
Hi everybody,

I am using ImageMagic in PHP to convert image files (JPG, GIF, PNG) to PDF. At first I thought this was no problem and I was able to set everything up easily.

PROBLEM:
Some images (some resolutions, some dimensions) convert to PDF but then display an empty or a misplaced image in the resulting PDF. Most images will convert correctly though...

TASKS:
- rotate image by -90 degrees
- center image on page
- force image into A4 format and size

CODE:
I am using the following command to perform the tasks:

Code: Select all

convert -rotate -90 -gravity center -page A4+0+0 source.jpg target.pdf 2>&1
QUESTIONS:
1.) What could possibly the problem why *some* images just won't convert correctly? Where is my mistake?
2.) Do I have to RESIZE or SCALE the images in any way to achieve what I want? Am I missing something?


Thank you very much in advance for any ideas!

Chris

Re: Problems with image to PDF conversion

Posted: 2011-06-05T11:54:26-07:00
by squirrel
SOLVED... kind of... ;-)

I took the "-gravity center" option completely out of the command and... now every generated PDF show the original image! :-) The only remaining issue is that the image is always aligned to the lower left corner of the page. That was actually the reason why I inserted the "-gravity center" option in the first place.

Cheers!