Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imagemagick convert multiple images to pdf size

For a project I am running ImageMagick to convert several images (all of the same size 960x570) into a single PDF.

The command I'm running is:

convert *.jpg pdf/export.pdf

Since the images are all the same size I expect each PDF page to be equal in size but this is not the case as you can see in the screenshot below:

example screenshot

This is bit annoying since I don't know how I can force the size of each PDF page to be the same.

I tested the PDF on both an android device, ubuntu pdf reader and adobe reader and they all show the different sizes.

Thanks for helping!

EDIT1: After testing out a few more things as suggested by Marc B and Basti I managed to put the same size on the JPG (uploaded) images.

The problem still persists with the images that are generated using webkit2png (Python script that converts a webpage/html file to an image). After trying (almost?) everything in the convert command I can't get these generated images to shop up properly in the PDF as you can see below:

enter image description here

Any help would be much appreciated!

like image 303
Kenny Avatar asked Mar 14 '12 16:03

Kenny


2 Answers

I found the solution:

I needed to add the following options to convert the image saved from webkit2png:

-density 960x570 -units PixelsPerInch

I hope this helps other people out too in the future ;)

like image 135
Kenny Avatar answered Sep 28 '22 06:09

Kenny


After a few seconds of using google, I found this:

-size <geometry> width and height of image

Example given by them:

$ convert -size 320x85 canvas:none -font Bookman-DemiItalic -pointsize 72 \ 
-draw "text 25,60 'Magick'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta \ 
-draw "text 20,55 'Magick'" fuzzy-magick.png

http://www.imagemagick.org/script/convert.php

like image 41
Basti Avatar answered Sep 28 '22 06:09

Basti