I want to convert a bunch of Webp images to individual PDFs. I'm able to do it with this command:

parallel convert '{} {.}.pdf' ::: *.webp

or I can use this FFMPEG command:

find ./ -name "*.webp" -exec dwebp {} -o {}.pdf \;

However during the process of conversion the Webp files are decoded and the resultant PDFs have a much bigger file size. When I use the above commands for JPG-to-PDF conversion the PDF size is reasonably close to the JPG image size.

This command works fine with JPGs, but the program img2pdf doesn't work with the Webp format:

find ./ -name "*.jpg" -exec img2pdf {} -o {}.pdf \;

I also tried Webp-to-PDF conversion with this online service, but the PDF was huge.

How can I keep the PDF size down to the Webp file size?

  • One possibility is to first convert the webp images to jpg, then to pdf. This might reduce the quality a little, but should work.
    – meuh
    Jan 15 '18 at 21:25
  • Yes this would work, but I am specifically asking how to do this with webp files.
    – whitewings
    Jan 16 '18 at 16:01
  • You will only get a small size pdf if you go via an intermediate jpg stage, as jpg compression is supported natively in pdf, but webp is not.
    – meuh
    Jan 16 '18 at 16:03
  • Could I get webp compression supported in pdf through some other program?
    – whitewings
    Jan 16 '18 at 18:22
  • Yeah, I guess until pdf supports webp natively (or someone writes a PS implementation of the webp decode in a way small enough to include in a PDF!) this won't be possible without losing significant quality Mar 21 '20 at 12:52

Why not just use Imagemagick and Ghostscript?

convert img.webp img.pdf
gs -sDEVICE=pdfwrite-dNOPAUSE -dBATCH -dPDFSETTINGS=/ebook -sOutputFile=img-small.pdf img.pdf

In my test with your sample file I got a pdf result of about 3.2 MB.


You could follow these instructions on Ubuntu to make sure that imagemagick was built with webp. Install this package for Windows or on macos do this:

brew install webp
brew install imagemagick
  • I have ImageMagick already and have tried some commands. Your command takes a series of webp images that amount to 2mb and creates a 100mb pdf. Even when I reduce the quality to 80 and the density to 50x50. I want a command that will give me a pdf that is roughly equal in size to the source webp images.
    – whitewings
    Jan 16 '18 at 15:59
  • @user8547 can you post a link to webp file example you are working on? Jan 16 '18 at 17:40
  • Here's a link. When I try all the methods of converting this to pdf it comes out around 150mb. cdn.pbrd.co/images/H3e1vmd.webp
    – whitewings
    Jan 16 '18 at 18:20
  • @user8547 updated with working sample script. Jan 16 '18 at 20:05
  • 1
    My bad - autocorrect bit again, it should be ebook without the camel case. I updated the answer for you Jan 17 '18 at 1:31

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.