Skip to content

Instantly share code, notes, and snippets.

@lukestanley
Last active May 4, 2020 14:47
Show Gist options
  • Save lukestanley/afd119f06649df2726faa8ce4e27c220 to your computer and use it in GitHub Desktop.
Save lukestanley/afd119f06649df2726faa8ce4e27c220 to your computer and use it in GitHub Desktop.
Compress PDF as JPG
# Adjust these variables as desired:
quality=80
density=200
convert -density $density "$1" -background white -alpha remove -alpha off -compress none BMP3:_temp_conv_file%02d.bmp
for f in _temp_conv_file*.bmp;
do
cjpeg -quality $quality -outfile "$f.jpg" "$f";
done;
img2pdf *.jpg -o "compressed_$1"
for f in _temp_conv_file*.bmp;
do
rm "$f.jpg";
rm "$f";
done;
@lukestanley
Copy link
Author

This could make a PDF larger. Variables may need adjusting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment