Page 1 of 1

Converting images into pdf files with equal sizes?

Posted: 2015-01-03T03:03:05-07:00
by csanyipal
Hi,
on my Arch linux I'm using ImageMagick 6.9.0-2 Q16 x86_64 2014-12-31.

I have a directory with many ( over 300 ) jpg images.
These images are scanned pages from a book.

Images have following properties:
geometry: 900x1200
resolution: 180x180

from the first image to the 27. image but from 28. image this is changing:
geometry: 900x1200
resolution: 150x150

I do converting these images into pdf files with command:

Code: Select all

for i in *.jpg; do convert ${i} ${i/.jpg/.pdf}; done
Then I merge these pdf files into one pdf file with command:

Code: Select all

pdftk *.pdf cat output valami.pdf
So as a result I get not equal pdf page sizes because from the 28.pdf pages are bigger in the same merged document.

How can I get equal pdf pages using the convert tool?

--
Regards, from Pal

Re: Converting images into pdf files with equal sizes?

Posted: 2015-01-03T05:32:33-07:00
by snibgo
Have you tried changing the resolution so they all match? Use "-density 180" or "-density 150".

Re: Converting images into pdf files with equal sizes?

Posted: 2015-01-03T05:46:58-07:00
by csanyipal
snibgo wrote:Have you tried changing the resolution so they all match? Use "-density 180" or "-density 150".
I solve the problem with these commands:

Code: Select all

mogrify -resize x1000 *.jpg
for i in *.jpg; do convert -density x1000 -units PixelsPerInch ${i} ${i}; done
for i in *.jpg; do convert ${i} ${i/.jpg/.pdf}; done
pdftk *.pdf cat output resulting.pdf verbose
pdf2djvu -o resulting.djvu resulting.pdf
The resulting pdf and djvu document has all pages same sized.
However, I don't really know what I did. Can one explain the:

Code: Select all

convert -density x1000 -units PixelsPerInch
part of code and whether must I before that command to resize images to the same 1000 pixels hight?

Re: Converting images into pdf files with equal sizes?

Posted: 2015-01-03T06:21:39-07:00
by snibgo
csanyipal wrote:So as a result I get not equal pdf page sizes ...
I think the problem is that your images had different resolutions: 180 or 150. So the cure is to make them all the same resolution, with "-density".

Re: Converting images into pdf files with equal sizes?

Posted: 2015-04-22T00:40:08-07:00
by dowcet
I was going to start a new question but this discussion seems closely related.

I have an image like this.

Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 2560x1280+0+0
Resolution: 300x300
Print size: 8.53333x4.26667
Units: PixelsPerInch

A density of 300 results in a very low-resolution PDF. Through trial and error I figured out that I had to set `-density 72` to get a PDF of the same resolution. How does this work exactly? Is there not some argument that will maintain the same resolution regardless of density?