Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.3: Create icon previews and more in the Terminal UNIX
I've wanted to generate icon previews for image files from the command line for a long time, even though there are many fine applications avaliable for this task (pic2icon, Photoshop, Graphic Converter, IconDropper, and PathFinder to name but a few). However, Panther includes the "scriptable image processing system," which makes this task trivial:
% sips --addIcon imagefile(s)
Use sips -h and sips -H for help, and see Apple's page on the new Image Events application

[robg adds: This looks to be a very powerful tool, hidden away in the recesses of 10.3. I can see some nice uses for this with my digital camera pictures. Definitely read the -h page for a brief look at everything it can do, and there's a bunch more info on the Apple page.]
    •    
  • Currently 1.86 / 5
  You rated: 3 / 5 (7 votes cast)
 
[16,398 views]  

10.3: Create icon previews and more in the Terminal | 8 comments | Create New Account
Click here to return to the '10.3: Create icon previews and more in the Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Check out PIL, too.
Authored by: SeanAhern on Nov 24, '03 05:18:03PM
I hafta say, sips looks pretty cool for doing all sorts of image manipulation from scripts.

For those looking for a bit more power (or the flexibility of Python), I have to also point to the free Python Imaging Library at http://www.pythonware.com/products/pil/.

I've used it on my OS X box for a good while now to help automate the creation and maintenance of my family web site. Python and OS X is such a nice combination!

(Not to dis Apple, just providing another option. Heck, these two could probably work in conjuction with each other well!)

---
-Sean

[ Reply to This | # ]

Quartz Scripting
Authored by: Andrew Shearer on Nov 24, '03 09:19:34PM

For Python scripters, there's also a comprehensive built-in interface to Panther's native graphics engine, Quartz. Resizing images can be 8 times faster with the heavily-optimized Quartz than PIL. The text, shape-drawing, and compositing features of Quartz are also available.

I have a sample code fragment for resizing JPEG images on my site.

If you have the Developer Tools installed, you can find other code samples focusing on the Quartz drawing and PDF features in /Developer/Examples/Quartz/Python/.



[ Reply to This | # ]
Can sips handle a whole bunch of folders?
Authored by: infodriveway on Nov 24, '03 10:03:51PM
This is probably a dumb question, but can I get sips to handle multiple directories (a subfolder of my Pictures folder)?

I was able to type:

sips -i
then drag a folder's worth of pictures (90 for this example) to the Terminal window to make custom icons. But I have LOTS of subfolders and it would be nice if sips could walk a directory structure instead of having to babysit each folder.

By the way, if anyone has used the Folder Actions for making previews by way of AppleScript and the Finder, this is MUCH FASTER!

Wow! Thanks for the great hint!



[ Reply to This | # ]

10.3: Create icon previews and more in the Terminal
Authored by: fxt on Nov 24, '03 10:33:56PM

> it would be nice if sips could walk a directory structure
> instead of having to babysit each folder.

if one has a bunch of folders with jpg images in them, then

% find . -iname "*.jpg" | xargs sips -i

will traverse the directory structure and add icon previews to each jpeg image.

fxt



[ Reply to This | # ]
10.3: Create icon previews and more in the Terminal
Authored by: dahjelle on Nov 25, '03 11:50:11PM

I had spaces in several of the file and directory names. This confused xargs because it, by default, uses spaces as the delimiters between file names. If you use

find . -iname "*.jpg" -print0 | xargs -0 sips -i
instead, find will delimit the file names with a '\0' and xargs will use the same character to send the arguments to sips.

Enjoy!



[ Reply to This | # ]
10.3: Create icon previews and more in the Terminal
Authored by: elmimmo on Feb 15, '04 03:50:29PM

It looked sort of a nice way to create thumbnails for image files, but it turned rather useless for me since instead of just adding a thumbnail, it seems to delete the original file after creating a copy of it, effectively erasing the original creation date and any custom comments the file might have. Is there any trick for it not to mess with more than just adding (or updating) an icon to the resource fork?



[ Reply to This | # ]
10.3: Create icon previews and more in the Terminal
Authored by: alys on May 06, '04 10:24:02PM

First, create a copy of your image file yourself. Run the sips command over that COPY. Then view the info for the modified image (cmd-i). At the top of the info window is the tiny icon. Click on the icon so that it's surrounded by a blue line (look carefully! It's not very obvious.) Do a Copy command to put the icon image in the clipboard. Now view the info for your original image, click on the icon and Paste.



[ Reply to This | # ]
10.3: Create icon previews and more in the Terminal
Authored by: Mikehkg on Dec 03, '07 09:24:57AM

re: It looked sort of a nice way to create thumbnails for image files, but it turned rather useless for me since instead of just adding a thumbnail, it seems to delete the original file after creating a copy of it

answer: This is due to your wrong command; just add the new filename you want for the thumbnail after the filename to be cp'd:

cp /Users/me/documents/large.jpg /Users/me/documents/small.jpg

then execute a second command to resize the thumb into the wanted size:
sips -Z 180 /Users/me/documents/small.jpg -- 180 is the target pixel size
i also like the rotate function:
sips -r 90 /Users/me/documents/small.jpg

Nothing beats a Mac.



[ Reply to This | # ]