Applescript to resize images by BOTH length and width?

I've searched for this, so please forgive me if I've somehow missed it. I'm looking for an Applescript that will resize both the length and width of an image. Ideally, I'd just like to save it to my desktop and drop images on it, resizing them to 250x166 pixels. Is this possible? I've seen scripts for length OR width, but nothing that will do both. I know, the images will be out of proportion, but for what I'm doing, that won't be an issue. Any help is greatly appreciated!

Posted on Dec 11, 2012 8:39 AM

Reply
6 replies

Dec 11, 2012 8:59 AM in response to steevfrumnj

Your request is a little unusual, which may be part of your problem.


The issue is that, usually, when you resize an image you want to scale it proportionally to maintain the same aspect ratio. Otherwise you end up distorting the image in one direction.

For example, if your image is, say 250 x 84px and you just double the height to get 166px, the image will distort and probably not look like what you wanted.


So what you want is probably a combination of scale, crop and/or pad. Scale proportionally increases or decreases the image's dimensions. crop trims an image to a certain size, and pad expands an image's boundaries to fill the space. Anything more than that requires additional thought as to what you want the image to look like.

Dec 11, 2012 9:46 AM in response to Camelot

Yeah, I know it's a little out of the ordinary.


This is a situation where the images, in their original state, will already be close in proportion to 250x166. But the originals will all be different sizes, so a scale by percentage script will not work for me.


I know that there may be some slight distortion, but "close enough" is good enough for what I'm using it for. Definitely don't need perfection!

Dec 11, 2012 9:54 AM in response to steevfrumnj

Have a look at Image Events the font end to the terminal command sips. I believe it should do what you are looking to do but as Camelot pointed out (and as you noted in your original post) the image will be distorted.


Message was edited by: Frank Caggiano The sips command that might do what you need to do is resample (-z) which does not appear to be in the IMage Events dictonary! So you'll need to drop into the shell for this, assuming resample does what you are looking for.

Dec 11, 2012 1:06 PM in response to steevfrumnj

I know that there may be some slight distortion, but "close enough" is good enough for what I'm using it for. Definitely don't need perfection!


Then it sounds like you need a combination of scale and crop - scale the image to the minimum size required (either 250 or 166, depending on its original size), followed by a crop to trim the other dimension to fit.


For example, if the original image is 260 x 250 you could scale it down to 250px wide (a .833 factor, which would end up with an image of 250 x 208), then crop the resulting image to 250 x 166.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript to resize images by BOTH length and width?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.