PDF with each page the same size from various images of different size.

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
TheAlmightyGuru
Posts: 4
Joined: 2017-08-14T11:27:10-07:00
Authentication code: 1151

PDF with each page the same size from various images of different size.

Post by TheAlmightyGuru »

Windows 7, Imagemagick 7.0.5.

I'm trying to create a PDF picture book from a collection of JPEG images where each page of the PDF is an image. I'm able to get a start by doing something like this:

Code: Select all

magick *.jpg output.pdf
However, since each page of the PDF takes on the metrics of the source image, and my images are of different sizes and DPIs, each page size in the PDF is radically different. I want each page to be the same size, but I don't want the images to be resized to fit the page. I want them centered on the page at their original resolution. I also want Imagemagick to ignore each image's internal DPI and treat all pixels as the same size. I know the largest width and height from the collection, so I will just use that as my page size to prevent cropping.

Does anyone know how I would go about doing that?

Thanks!
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: PDF with each page the same size from various images of different size.

Post by GeeMack »

TheAlmightyGuru wrote: 2017-08-14T12:24:14-07:00However, since each page of the PDF takes on the metrics of the source image, and my images are of different sizes and DPIs, each page size in the PDF is radically different. I want each page to be the same size, but I don't want the images to be resized to fit the page. I want them centered on the page at their original resolution. I also want Imagemagick to ignore each image's internal DPI and treat all pixels as the same size. I know the largest width and height from the collection, so I will just use that as my page size to prevent cropping.
Include an "-extent" operation in your command like this...

Code: Select all

magick *.jpg -background white -gravity center -extent WxH output.pdf
Use whatever dimension you require for the width "W" and height "H" in that command. It will center all your images, each in a page the size you specify.
TheAlmightyGuru
Posts: 4
Joined: 2017-08-14T11:27:10-07:00
Authentication code: 1151

Re: PDF with each page the same size from various images of different size.

Post by TheAlmightyGuru »

Thank you so much GeeMack! That was exactly what I was looking for.

I should add that, with -extent in place, I was able to use -density 72 successfully to get all of the DPIs to look the same despite their varying DPI.
Post Reply