Many digital cameras and smart phones can easily produce large JPEG image files over 1 MB and even up to 40 MB but, for someone working over the Internet, or in limited space, downloading a directory of such images may take too long or be prohibitively costly. For many web applications, smaller and lower quality photographs are at least acceptable and even preferred for photographs of ephemeral interest where an everyday experience is being shared but which will be forgotten or was only sent to create envy or FOMO.
Most existing image editing programs like The Gimpoffer interactive dialogues that enable one to choose the most appropriate compromise between file size and image quality individually for each image. However, editing all ones photographs by hand just to produce a copied set with smaller file sizes is a waste of effort when other programs can automate this task for you. Apple Mac owners can use the batch features of iPhotowhich is free with Mac OS X, but for others, you might like to try this Java application called JPEGDirCopy from Jeremy Parsons. The latest version of JPEGDirCopy (version 2.4) uses a new image compression library org.imgscalr written carefully for optimal results and runs in parallel using all the the CPU cores in your computer for extra speed but it does assume that sufficient RAM is available for the number of cores discovered all to work simultaneously. Version 2.4 (written in 2022) should work with Java version 9 to Java 17 after replacing code that used deprecated classes in com.sun.image.codec.jpeg and adding a module-info.java file to enable use with modularised JAVA which appeared long ago in Java 9!
The JPEGDirCopy Java application has both a command-line and a GUI interface. The GUI is shown above and is very clunky by the standards of normal distributed software, but it works - just. Download the JPEGDirCopy.jar from the software download directory, ensure you have a working version of Java2, and then choose either the command line or the GUI interfaces.
Once all the values have been set, and you have pressed each of the left
hand buttons (important), then press the "Start Copying" button and watch
it go. I use the JPEG copier to produce greatly compressed pictures for
email and web publishing though certain scenes compress much better than
others.
java -jar JPEGDirCopy.jar
java -cp JPEGDirCopy.jar com.jeremyparsons.imaging.JPEGDirCopy original_directory_name copied_directory_name width_in_pixels height_in_pixels quality(0.1 - 0.9, 0.8 default) maximise_compatibility(true|false) UltraQuality(true|false) degrain(true|false)
java -cp JPEGDirCopy.jar com.jeremyparsons.imaging.JPEGDirCopy original_big_dir new_small_dir 1200 800 0.8 true false false
A good compromise between file size, quality, and the expected available screen space of a typical Web surfer would be to use an image size of 800 by 700 pixels and a JPEG quality level of 0.70 to give a typical file size of 70 KB though highly detailed photographs of forests, complex textures etc. would be around 100KB and sunsets or big blue skies around 30KB.
Be warned that when the program runs, it makes a smaller copy of every JPEG file that it finds in all the subdirectories of the first folder that you specify so avoid specifying the top of big directory trees and also avoid copying recursively (where the output folder is a subdirectory of the input folder). The program tries never to delete a single file so it should not really be dangerous but you should test it carefully first and check the source code.
The program is written in Java and you can download the very latest version from http://java.sun.com/ from oracle or from openjdk
Littlest Home Page | Jeremy Parsons' Home Page |