简体   繁体   中英

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:

示例截图

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:

在此输入图像描述

Any help would be much appreciated!

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 ;)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM