Mass Image Compression


I have a massive set of project folders in a directory that each contain subfolders with jpg images; the people that took the pictures at the time used high quality settings on the camera which makes these images quite big in size; I run a backup everynight of this directory and the resulting size of the backup is getting huge and takes an eternity to process. The images don't need to be as big as they are...

I was wondering if there was a software that could scan this directory and all subfolders and compress these images to half their size without my intervention or me having to process each folder one by one.

Most software requires you to specify where to save the images, which folder to compress, etc... But I would want the compressed image to replace the uncompressed one...

Anyone know if this is possible?

Thank you
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
I would use the Batch Processing on irfanview. It enables you to overwrite the images, resize and compress them with a different JPG encoding. See the Advanced Options dialog in the File-Batch Processing
Actually, you don't want to compress them. They are already as compressed as they can get. What you want to do is to resize them. If you Google "batch resize" you will find all sorts of programs to do that.

The freeware IrFanView is just one example:
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
They are not already as compressed as they can get. They are compressed using an encoding based on a certain %.

You can change the % and have them compressed to a different extent. You will lose image quality if you do, but you will do that if you resize as well.
dbruntonQuid, Me Anxius Sum?  Illegitimi non carborundum.Commented:

First if you've got various projects I'd assume that some of them are finished and no longer being used.  If that is true then backup them up to some other medium or storage device and then delete the projects from your system.

Do experiment with the resizing and quality options first with your users/developers before going that way.  You can go that way but you can't reverse if you need to.
Joe Winograd, Fellow&MVEDeveloperCommented:
As Phillip already mentioned, IrfanView (fantastic piece of free software!) can do it, but only via the GUI. So if it's a one-time run and you're willing to use the GUI to set the options manually, it's a fine tool for the job. But if you want to create a batch file to do it, then IrfanView is not the right tool — note this comment in its command line documentation:
some Misc. Advanced Batch options are not supported: overwrite, delete, subfolders, all pages
Since you need the overwrite option, the IrfanView command line won't do it for you.

What will do it is GraphicsMagick. After downloading and installing it, here's a batch file calling the gm command line that does what you want:

FOR /R "C:\StartingFolder\" %%G in (.) DO (
  Pushd %%G
  gm mogrify -quality xxx *.jpg
  Popd )

Open in new window

Of course, change the starting folder and quality setting (see below) to whatever you want.

Two important notes: (1) The mogrify option overwrites the existing file with no warning — be careful! Back 'em up before running the script, just to be safe. (2) The quality option value (xxx above) is your ticket to the reduced file size. Possible values are 0 (lowest quality, smallest file size) to 100 (highest quality, largest file size). For example, I just tested it on a JPG that was 1521 KB — here are the results:

-quality 0              51 KB
-quality 25          283 KB
-quality 50          436 KB
-quality 75          627 KB
-quality 90        1521 KB
-quality 100      2863 KB

I suggest experimenting with several quality settings on a few of your files in order to determine a balance of quality and file size that you're happy with (before turning it loose on the massive set of folders). Regards, Joe

Update: I decided to write an article about this:
Reduce the file size of many JPG files in many folders via an automated, mass, batch compression method

If you get a chance to read it, please let me know what you think of it — and kindly give it an "upvote" if you like it. Thanks, Joe

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Images and Photos

From novice to tech pro — start learning today.