Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Resize images from command line

Resize images from command line
Thread Tools
jld
Dedicated MacNNer
Join Date: Dec 2003
Location: 98122
Status: Offline
Reply With Quote
May 15, 2004, 04:12 AM
 
I want to write a script that will resize any images in a certain directory that are bigger than given x,y sizes.

Anyone know a command, or application that will allow me to do that?
12" AlBook • 15" Albook • G4 Cube • iSight • Original iPod • PB 100 • Newton 110 • Quicktake 100
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
May 15, 2004, 07:48 PM
 
Applescript: Image Events
Command-Line: man SIPS
     
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status: Offline
Reply With Quote
May 15, 2004, 08:45 PM
 
You could also install ImageMagick via darwinports or fink.
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
May 15, 2004, 10:39 PM
 
he means

sips --help
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
May 16, 2004, 01:29 AM
 
Definitely get imagemagick. I had a chance to dig into it 2 weeks ago for a project I'm working on, so I have some info handy.

Download link


Here's a simple shell script I wrote to resize every jpeg in a folder

#!/bin/sh

for image in `ls *.JPG`
do
/usr/local/bin/convert -interlace none -quality 90 -thumbnail 600X800 $image 'th_'$image
done


edit as needed.
the .JPG part above is case sensitive. Adjust the with and height, etc..

-quality can be whatever you want 1-100
-thumbnail strips out the extra info you don't need for the internet like preview images and meta info. - some of which crash IE on win.
-interlace none added for IE win safety as well.

it can do a lot more - basically it's a command line photoshop.
full docs:
http://www.imagemagick.org/www/utilities.html

there's probly a 'make smaller only' flag to do what you want. You can also set a width only and the height will be proportional, etc.


this script needs to be in the same folder as the pix.
save it as resize_graphics.sh
you need to set it to be executable:

chmod 755 resize_graphics.sh

run it like this:
cd /path/to folder
./resize_graphics.sh

If the pix are big you may need to be patient.

Have fun
(Last edited by Gavin; May 16, 2004 at 01:37 AM. )
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
May 16, 2004, 06:06 AM
 
Or you could use the CoreGraphics python bindings to hack up a quick script. See /Developer/Examples/Quartz/Python
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:43 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2