Join 3,430 readers in helping fund MetaFilter (Hide)


How to automatically degrade jpg quality to fit in a given space
April 27, 2012 5:44 PM   Subscribe

How can I compress/resize thousands of jpgs to fit exactly into the space of a DVD automatically?

I have about 10,000 scanned notebook pages saved as jpgs. The average size per file is 1.5mb and the average resolution in 2000px x 3000px. Is there some way to automatically compress the images so that they will all fit exactly on a DVD? The images are largely handwritten notebook pages. I am on a mac and I have Photoshop and Toast but would be willing to buy software to do exactly this thing. This is an ongoing project and the number of files will increase at some point (Think dvd version 1, version 1.1 etc). Ideally I would be able to compress/resize the images from the masters and produce a disk image that I could then burn on to multiple DVDs. These DVDs will then be given to people for viewing on regular home computers. The files are organized in to folders based on notebook volume with an average of 100 files per folder. What is the best way to do this?
posted by Infernarl to Computers & Internet (5 answers total) 1 user marked this as a favorite
 
I believe irfanview batch resize will let you specify a max file size. You can do some simple math to figure out what that number should be and let it go to town.
posted by jsturgill at 5:56 PM on April 27, 2012


There's a lot of software that can compress an individual image to an exact size. So you could compress each image to 4.71GB / 10,000 = 471k and they'd just fit. (I'd go with 465k to be safe). jsturgill's suggestion of irfanview sounds promising for compressing each image to a specific filesize. Unfortunately my favorite tool graphicsmagick doesn't seem to have that option.

Compressing each image to a specific size is not optimal if the images are wildly different; ideally you'd want to compress simple images to smaller sizes and complex images to bigger sizes. I don't know of any program that will do that kind of optimization across a set of images. If all your images are scanned notebook pages then it's probably not worth worrying about, they're all pretty similar.

You may also want to take a quick look at converting to PDF. Normally PDF is a horrible format, but it has good support for scanned pages.
posted by Nelson at 6:01 PM on April 27, 2012


You can't tell exactly how much space a JPEG image is going to take up when it's compressed without compressing it, and more complex images don't compress as well as smaller ones, so to do this optimally is essentially impossible. You can do it well enough, though, with the suggested solutions, by limiting each image to a particular size. This does poorly in cases like the following: you set a limit of 2mb/picture and one of your pictures is a single white pixel, and so at maximum quality it's still only a few bytes, but another image is a 5000x5000 pixel high-quality photo with lots of fine detail in it. You compress it to 2mb and lose a lot of quality. Ideally, you could have used the leftover space from the small image and allowed for this image to be just under 4mb, with higher quality. That's not really feasible, though.

For plain text though, convert them all to 1 bit per pixel black and white images and they'll take up almost no space (they'll look like faxes, though).
posted by tylerkaraszewski at 8:57 PM on April 27, 2012


Additionally to tylerkaraszewski, It kind of depends on whether you just want them all to fit on one disk or you want all of them saved at the same reduction in quality no matter what, in which case the solution will be by trial and error.

Furthermore, image files are binary and JPGs are already compressed (duh), so if your send-around disks are supposed to be inflated into full-quality image files, that's not going to work. That's why JPG exists, therefore there's very little difference between a zip file of images at maximum compression and once full of images with no compression ("store" mode, or a tarfile). For your versioning idea, I would just keep a master directory of uncompressed images which are shrunk to DVDs based on whatever future criteria you need to keep them on one DVD, and use those settings in a script. You could automate size-finding by having the script run the entire process, create a DVD ISO, and compare the size to see if it will fit, reducing the compression quality and starting over if over 4.7GB or whatever.
posted by rhizome at 11:34 PM on April 27, 2012


ImageMagick is the command-line suite of tools for manipulating images, and is available for OS X. You'll want to investigate the "convert" (to create a new file with the attributes you like from the original) command.

Creating your DVD media should then be easily scriptable.
posted by namewithoutwords at 3:35 AM on April 28, 2012 [2 favorites]


« Older When I was a kid in southeast ...   |  I'm 24, I've been kicked out o... Newer »
This thread is closed to new comments.