Starting to feel good about this! Had to figure out pixel orientation in photos (portrait photos in cameras are still laid out horizontally, with just a flag to rotate them in software), and also programmatically lay it out tens of thousands of times to find the most optimal configuration.
This is a screenshot of a 680MB PDF where each image is in the original resolution.