Hacker News new | ask | show | jobs
by quibono 54 days ago
Nice, I’ll definitely check this out. You might want to look at optimising the PDF, it’s sitting at 40MB right now.
2 comments

Thanks! I think most of the weight comes from the PNG diagrams, but I don’t actually know: I’ll put it on my to-do list to investigate, maybe there are some easy wins here.
The ~750 pngs are about 15 megabytes. The 77 photographic images are 22 megabytes.

Somewhat a death of 1000 cuts.

I used https://www.xpdfreader.com/pdfimages-man.html to extract them and take a look.

Thanks for that. At first glance, it looks like that is a good place to be, regarding images. I will still investigate when I find time.
Probably the main thing you could look at is what pixel density you want in your images.

For example, there's a 1 megabyte image of a tanker trailer that is displayed at about 1.5 x 3 inches, you could get rid of 3/4 of those pixels (going from ~400 ppi to ~200 ppi) and not really change the quality of the image for a casual reader.

that’s a really good place to start, thank you!
One week later, a follow-up. I went through the largest JPG files and was able to shave 7 MB off the final PDF file size, with no noticeable drop in quality, as far as I can tell: https://framagit.org/olivier/thermodynamique/-/commit/063038...

As for the PNG files, I gave up after spending a whole day on them. I was able to compress them losslessly to save 6 MB, but this did not carry over into the PDF, where they are not embedded but re-encoded. The best way to save space here would be to switch to SVG, but this is too much work and last time I tried 12 years ago it did not work well. Alternatively, removing transparency would help (and anyway the source SVG is given for each file). But that’s not very future-proof and somewhere I know there’s a teacher who just is going to right-click-save a diagram and will get a nice crisp transparent-background PNG they can instantly reuse. Verdict: at this point, I am calling it good enough. :-)

Claude was able to optimize the hell out of one of mine, might be worth a try
Does it matter?