Does Typst have a native way to compress images to decrease the PDF file size?

I have a Typst document with about 120 images of various sizes. When I compile it, the resulting PDF is about 24 MB large. By using Adobe Acrobat, I was able to compress the images and reduce the PDF down to 6.5 MB without much visible quality loss.

Does Typst have native functionality to set image compression or do I still have to use external tools?

Doesn’t seem like it :( relevant compiler issue: Allow limiting the image resolution · Issue #2554 · typst/typst · GitHub

This may help inform automated pre/post processing via third party tools: Why does typst generate much larger pdf than TeX? · typst/typst · Discussion #404 · GitHub. People have so far mentioned using Compress PDF | Reduce PDF File Size Online for Free, commands from How to Compress PDF in Linux [GUI & Terminal], and pdfcpu optimize file.pdf.

I wonder if someone has made a typst package that applies compression across all images? My rudimentary google search didn’t pick anything up.

1 Like

No native way, although I think it re-encodes PNG as JPEG. GitHub - oxipng/oxipng: Multithreaded PNG optimizer written in Rust was recommended for optimizing PNG images. JPEG usually always turn out very small when included in the PDF. Might be re-encoded/optimized.