Problems with image to PDF conversion

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
squirrel
Posts: 2
Joined: 2011-06-05T08:19:10-07:00
Authentication code: 8675308

Problems with image to PDF conversion

Post 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
squirrel
Posts: 2
Joined: 2011-06-05T08:19:10-07:00
Authentication code: 8675308

Re: Problems with image to PDF conversion

Post 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!
Post Reply