Page 1 of 1

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

Posted: 2017-08-14T12:24:14-07:00
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!

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

Posted: 2017-08-14T12:50:53-07:00
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.

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

Posted: 2017-08-14T13:11:23-07:00
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.