0

I have a pdf file created from an impress presentation. I want to convert the pdf to png images to add them to create a video using them. I am using pdftoppm to convert the pdf to png, but the exported images are getting a size of 1654x931 px. I need 1920x1080, as my video is going to be in that resolution.

The command I am using is the following:

pdftoppm -png report.pdf report

In Impress I haven't found any setting the set the size of the exported pdf, and I haven't been able to find anything to set the size of the png conversion.

Is there anyway to adjust the size of the generated pngs?

3
  • Does your version of pdftoppm not have a -scale-to option? May 30 '20 at 15:02
  • actually, that worked fine. I had to use scale-to-y andscale-to-x. If you post it as an answer, I would mark as the accepted answer
    – jjcasmar
    May 30 '20 at 19:05
  • Thanks - I have added a brief answer below May 30 '20 at 19:35
1

pdftoppm appears to provide the following scaling options:

   -scale-to number
          Scales  the  long  side of each page (width for landscape pages,
          height for portrait pages) to fit in scale-to pixels.  The  size
          of  the short side will be determined by the aspect ratio of the
          page.

   -scale-to-x number
          Scales each page horizontally to fit in  scale-to-x  pixels.  If
          scale-to-y  is  set  to -1, the vertical size will determined by
          the aspect ratio of the page.

   -scale-to-y number
          Scales each page vertically to  fit  in  scale-to-y  pixels.  If
          scale-to-x  is set to -1, the horizontal size will determined by
          the aspect ratio of the page.

Since 1654x931 and 1920x1080 have essentially the same aspect 16:9 ratio, it may be sufficient to use -scale-to to set the long edge to 1920 pixels:

pdftoppm -png -scale-to 1920 report.pdf report

Otherwise, you can set the x and y dimensions explicitly

pdftoppm -png -scale-to-x 1920 -scale-to-y 1080 report.pdf report
0

I'm not very familiar with *.cbr / *.cbz, but it seems you'll have to combine two steps:

Convert PDF to Images

Compress them into a ZIP / RAR archive.

Regarding step 1, you could use ImageMagick's convert command. You can feed convert with a PDf comprising multiple pages, and convert will return each page as single graphics file. I've tested it with a text scanned at 400 dpi, and the following command resulted in nice single JPGEs:

$ convert -verbose -colorspace RGB -interlace none -density 400 -quality 100 yourPdfFile.pdf 00%d.jpeg

(credits regarding the -quality option: this forum entry)

As a result, you get 000.jpeg, 001.jpeg and so on. Just zip them into a .cbz file, and you're done.

You could even combine both steps by "concatenating" them:

*$ convert -verbose -colorspace RGB -interlace none -density 400 -quality 100 yourPdfFile.pdf 00%d.jpg && zip -vm comic.cbz .jpg

(make sure that there aren't any other JPEGs in your current working directory, since using the code above, zip will move all JPEGs into the cbz file)

1
  • OP didn't mention *.cbr or *.cbz files. Wrong question?
    – Freddy
    Jul 6 '20 at 20:37

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.