ExifTool Forum

ExifTool => Newbies => Topic started by: richimages on January 02, 2015, 02:08:05 PM

Title: Reducing images if over a MaxDimension (also, can this be done for Dir Stucture?
Post by: richimages on January 02, 2015, 02:08:05 PM
Greeting Phil,

I have a request.  I've uploaded (over the years) several images (that should have been reduced to a smaller size) to a server that's running my WordPress blog.   Images are uploaded to a directory tree structure of ~/wp-content/uploads/YYYY/MM/DD

I want to tar that original directory, download it to my Mac, and reduce large images to smaller versions before I upload and replace the directory structure on the WordPress server.   So, ultimately, I want to walk that directory and downsize (keeping the same aspect ratio) any image whose horizontal or vertical size is greater than 1280 pixels.   I want to downsize those images to have a 1280 max dimension.  Any images that are reduced need to be overwritten to have the exact same name (as those filenames are referred to by the WordPress database).

Is this something that is rather difficult or easy?  I can used anything - exiftool comes to mind as a first stab at this.

Suggestions?

Thanks so much for any advice

Richard Walters
Title: Re: Reducing images if over a MaxDimension (also, can this be done for Dir Stucture?
Post by: StarGeek on January 02, 2015, 04:05:43 PM
ExifTool will only change metadata.  It cannot do any image processing.

You'll want to look into a batch resizing program.  Unfortunately, I am not familiar with mac programs to suggest something.  On Windows I would use Irfanview to do it.

Title: Re: Reducing images if over a MaxDimension (also, can this be done for Dir Stucture?
Post by: Hayo Baan on January 03, 2015, 08:44:24 AM
Hi Richard,

On a Mac, have a look at the standard available command called sips (stands for scriptable image processing system). man sips will tell you all you need to know. sips is not the most advanced tool available, but it is installed by default and does resizing quite well. You can even have it fill blank space with a default background colour. I use it to create images for my desktop screensaver that are the exact size of my display. For instance:
sips --setProperty format jpeg --setProperty formatOptions "90" --matchToWithIntent "/System/Library/ColorSync/Profiles/sRGB Profile.icc" "perceptual" --resampleWidth 1920 --padToHeightWidth 1200 1920 --padColor 333333 "$source" --out "$target"
The command first specifies it should create a jpg with 90% quality, converting it to sRGB with perceptual matching intent. It tells it to first resample it to 1920x1920 and then to pad/crop it to 1920x1200 (sips has x and y switched...) with a dark grey fill colour. $source is the source image, and $target is the target file.

Hope this work for you too,
Hayo
Title: Re: Reducing images if over a MaxDimension (also, can this be done for Dir Stucture?
Post by: richimages on January 03, 2015, 10:06:26 AM
  Thanks for the replies ...

Hayo Baan - that looks promising, I'll see if I can cobble together a script that will walk the directory structure, and make calls to that command. 

always learning ...

Title: Re: Reducing images if over a MaxDimension (also, can this be done for Dir Stucture?
Post by: Alan Clifford on January 03, 2015, 05:50:57 PM
What my resizing script ultimately uses is mogrify, which is part of ImageMagick http://www.imagemagick.org/