Re: do shell script and ImageMagick
Re: do shell script and ImageMagick
- Subject: Re: do shell script and ImageMagick
- From: Ken Tozier <email@hidden>
- Date: Sun, 25 May 2003 15:03:54 -0400
After further experimentation, I found out how to get simple
ImageMagick commands working in "do shell script" and am providing the
method here in case others might want to try ImageMagick out.
First, read Apple's tech note regarding full path names to shell
commands, located here:
http://developer.apple.com/technotes/tn2002/tn2065.html
Second, ImageMagick needs the use of various libraries when it's doing
it's stuff. The paths to these libraries need to be included in
commands run with "do shell script". You can create properties for
these paths in your script and just prefix these properties to every
command sent to ImageMagick.
For example, to convert every photo ending with ".JPG" in a specified
directory to thumbnails, you could do something like this:
(Note: this example assumes that you installed ImageMagick 5.5.7 into
your "/usr/local" folder, If you have a different version or installed
it in some other location, modify "pathToImageMagickLibraries" and
"pathToImageMagickCommands" accordingly)
-- Set up properties likely to be used in multiple commands
property pathToImageMagickLibraries:"export
DYLD_LIBRARY_PATH=/usr/local/ImageMagick-5.5.7/lib;"
property pathToImageMagickCommands:"/usr/local/ImageMagick-5.5.7/bin/"
-- Specify variables for use in the thumbnail command
set pathToImagesFolder to quoted form of POSIX path of (((path to
desktop) as string & "test folder") as alias)
set thumbWidth to 180
set thumbHeight to 180
-- Build the shell command
set cmd to pathToImageMagickLibraries & pathToImageMagickCommands
set cmd to cmd & "mogrify -size " & thumbWidth & "x" & thumbHeight &
space -- "mogrify is an ImageMagick command
set cmd to cmd & "-resize " & thumbWidth & "x" & thumbHeight & space
set cmd to cmd & pathToFolderContainingImages & "*.JPG"
-- Execute the command
do shell script cmd
Viola! You now have a folder full of thumbnails scaled proportionally
so their largest side equals 180 pixels.
I'm just scratching the surface with ImageMagick myself, but it's core
feature set seems to compare quite well, quality-wise, with PhotoShop
and it's completely free.
Hope others find this of some use. Enjoy,
Ken
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.