Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/mrgnw/scripts.
Something went wrong. Try again.
12345678910111213141516171819202122232425#!/bin/zsh
input_pdf="$1"if [[ ! -f "$input_pdf" ]]; then echo "Usage: $0 <pdf-file>" exit 1fi
pdf_name="${input_pdf:r}"output_dir=$(mktemp -d)
# Extract all imagespdfimages -all "$input_pdf" "$output_dir/page"
# Optimize all extracted images (lossless)optimizt "$output_dir"/*
# Recreate PDFimg2pdf "$output_dir"/* -o "${pdf_name}-opt.pdf"
# Cleanup temporary directoryrm -rf "$output_dir"
echo "Optimized PDF created: ${pdf_name}-opt.pdf"