1

I want to convert a pdf to jpg. The page size is not standard. (pdf here: imslp)

When I convert the pdf to jpg with convert -density 300 sheet.pdf sheet.jpg, I get this: Converted image. (The difference is not really clear in the browser. Download the file to see the extra white space)

As you can see, imagemagick changed the size of the paper, so extra space is added.

I want to maintain the page size. How can I do this?

1

I suggest you to use pdfimages instead of convert.
With pdfimages -list Test.pdf I obtain the list of the images of the pdf file.

page   num  type   width height color comp bpc  enc interp  object ID
---------------------------------------------------------------------
   1     0 image    4128  5440  gray    1   1  ccitt  no        97  0
   2     1 image    4112  5424  gray    1   1  ccitt  no        95  0
   3     2 image    4080  5440  gray    1   1  ccitt  no        93  0
   4     3 image    4096  5440  gray    1   1  jbig2  no        12  0
   5     4 image    4176  5488  gray    1   1  jbig2  no        16  0

So the images inside your pdf have different sizes and encryption.
With the following command you will extract them all:

pdfimages test.pdf sheet

It will give progressive names sheet-000.pbm sheet-001.pbm sheet-002.pbm sheet-003.pbm sheet-004.pbm and it will write them in pbm format.
Unfortunately the option -j doesn't work in your specific case and you have to convert by hands:

convert sheet-001.pbm sheet-001.jpg

At this point you will have the images with their the original size.


Now the core of your question: which page size?!?

 A4        210   × 297   mm   at 300 dpi     2480 x 3508 Pixels 
 Letter    215.9 × 279.4 mm   at 300 dpi     2550 x 3300 Pixels
 ...

Let we choose A4.
The ratio do not fit the ratio of your pages so you can or distort it or leave with some white space over or with some white space on a side.

 convert sheet-001.pbm -resize 2480x3508\! distort.jpg      # you fix xy
 convert sheet-001.pbm -resize 2480x       Take_Width.jpg   # you fix x
 convert sheet-001.pbm -resize x3508       Take_Height.jpg  # you fix y

To install pdfimages you can install the poppler-utils. Search for your operating system.

Ps> How to do calculations

 Letter    8.5 x 11 inches    x 300 dpi  ---> 2550 x 3300 Pixels

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.