RSSAmplifier

Peter Babič · Jan 8, 2025

Merge photos into pdf via cmd

0
Sign in to vote or save

Peter Babič · Peter Babič

Here’s a short function for fish shell I am currently using to merge photos into one pdf and then optimize it to massively reduce the resulting size, for instance from 13MB to 230kB without loosing too much quality. Works for me very well, requires GhostScript and ImageMagick 7 or higher:

function pdfm
    set output_file $argv[-1]
    set -e argv[-1]
    set tmp_file "tmp_file.pdf"

    magick $argv "$tmp_file"
    gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$output_file" "$tmp_file"
    rm "$tmp_file"
end

Use it like this:

pdfm photo1.jpg photo2.png document3.pdf output.pdf

Enjoy!

Links #

Loading comments...

Read the original on peterbabic.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.