Convert jpeg quality to 80% using automator

1

I want to make a automator script that goes trough a folder with subfolders and convert all .JPEG (or .JPG) to the same JPEG, but with a quality of 80%.

There is no option in Automator it self like there is in Preview, Pixelmator or Photoshop when saving the JPEG to set the quality. So I installed ImageMagick via homebrew, but I don't know how to pass it functions trough automator.

TL;DR: convert only JPEG in folder with sub folders to a lower quality using automator and don't move the files.

juistm

Posted 2015-06-19T12:15:26.727

Reputation: 111

Answers

1

In the imagemagick package there is a program called mogrify that will overwrite the original image file, and another, convert, that will write to a different image file.

In Linux there is another command, find, that will search (and find) all the files in a path that will fullfill the search criteria and that can execute some command with the filename found.

Warning: I strongly suggest to do a backup before starting to use a script that will modify the original files, just to prevent any unpleasant inconvenience that you cannot fix after...

Moreover I suggest you to test the command on a sample (only on some files and not on all).

I understand you want to replace all your images with a lower quality version.
Merging the above two command you can do something similar to

find Path/to/MyFolder -name '*.jpg' -exec mogrify -quality 80 {} \;

Use man mogrify and man find to have some hints more.

Hastur

Posted 2015-06-19T12:15:26.727

Reputation: 15 043

I have this script find . -type f -iname "*.jpg" -exec convert \{\} -quality 80 \{\} \; and it works fine in a terminal window if I cd Path/to/MyFolder but its not working in side automator. – juistm – 2015-06-23T17:11:01.327

I have no mac to test it now... but you can run this command as a little script to overcome the problem. BTW You should have problem to convert a file with the same name for input and output (they did mogrify for it). Moreover it sounds me strange the protection for \{\} ( it should be {}) – Hastur – 2015-06-23T17:39:22.693

Just a try: Try to substitute "*.jpg" with '*.jpg'... or to escape the " with -iname \"*.jpg\" – Hastur – 2015-06-25T14:06:27.180

would upvote 5 times if i could! Thank you! – AlexDrenea – 2019-08-25T13:36:23.623

@AlexDrenea You're welcome. BTW for what specifically? – Hastur – 2019-08-25T15:24:21.150

@Hastur I would have never found the mogify command on my own (such a werid name).... I'm using it to batch convert pictures taken with a camera at JPEG Super Fine setting (which is essentially JPEG 100). There is no visible difference between the 80 and 100 quality (barely visible at 100% crop) but the size if 3-4 times lower. – AlexDrenea – 2019-08-27T01:41:12.513

@AlexDrenea Since you want to use it for the_original_ photos, I strongly suggest to test some lossless format. Even the simple PNG or the TIFF (lossless) one. Once you decrease the quality you will not have the possibility to come back... and even if it is satisfactory, it may happen that in some years you may need it back. :-). PS> You may even try to compress with rar or 7z...

– Hastur – 2019-08-28T17:14:27.603

@Hastur thanks for the suggestion. I've built a system over the years where I do an initial selection of photos that are really good and store the original RAW image for those. For the hundreds of others, that I know i'm likely never touching again, I just convert them to JPEG 80 so they are easily stored and viewed in the future. – AlexDrenea – 2019-08-29T22:36:14.597