Here goes!
- I have a folder with dozens of sub folders which contain sub folders
- I would like to resize all images which have any length greater than 800px so the new length becomes 800px but the image maintains the same ratio. For example if an image was 1200x600px it would resize it to 800x400px
- I would then like it to be "Saved For Web" or optimised at the very least It would then have to overwrite the original since I am using GIFs, JPEGs, JPGs and PNGs
Can this be done all together, can any part be easily done?
I'm on a Mac
Thanks in advance
I would do it with ImageMagick. The command is like this, but I would create a backup first:
That says... starting at
dot
(the current directory, you can put a different starting directory here if you like), find all files called ".JPG" or ".JPEG" or ".GIF" or ".PNG", regardless of upper or lower case, in this directory and all directories below, and pass their names into the while loop. Theconvert
command says to resize the image so neither side is over 800px and the aspect ratio is retained, then optimise for Web and overwrite original file.At the moment, it does nothing, it just shows you the command it would run, so you would need to remove the word
echo
and run it again if you like it. Run some tests on a single image or two first.You could add
-strip
between-resize
and-quality
to remove EXIF data (date/time photo was taken, camera make and lens etc) to make the files smaller too. You can also insert a Copyright string and an IPTC profile to give Copyright, Contact, Source, Object and Credits information - just ask me.To run the script above, save it in a file called
resizer
, then go into Terminal and do this:To install ImageMagick on a Mac, use
homebrew
. Go to here and install it with the line of code there. Then do:If you don't like ImageMagick, you could maybe use
sips
which is built into OSX but it is nowhere near as flexible. If you wanted to try that, the basic command would be:and it will then resize the image to max 800px on either side. Not sure how to optimise or strip EXIF in
sips
, nor if it works forPNG
andGIF
files... Your command would then become: