Thursday, 7 August 2025

Converting images to pdf in Linux

Occasionally, I have to scan official papers (dead-tree-copy) and I'd like to keep the result small, and in one pdf.

So, a one liner command would be nice.

magick mrbear*.png -quality 10% -set filename:base "%[basename]" "%[filename:base].jpg"

The commandline above automatically creates an appropriate .jpg file for each mrbear*.png file. So mrbear_0001.png will cause a mrbear_0001.jpg.

Just what I wanted. Went from 8 megabytes picture to a 200 kb picture.

And then converting the new images over to a pdf file is ridiculously simple:

magick mrbear*.jpg mrbear.pdf

Magick!

References

DigitalOcean - Reduce File Size of Images in Linux - CLI and GUI methods
https://www.digitalocean.com/community/tutorials/reduce-file-size-of-images-linux
GitHub - Convert images but keep the original file name #6494
https://github.com/ImageMagick/ImageMagick/discussions/6494
ImageMagick
https://imagemagick.org/

No comments:

Post a Comment