Do Shell Script Bug (or feature)
Do Shell Script Bug (or feature)
- Subject: Do Shell Script Bug (or feature)
- From: Chris Norman <email@hidden>
- Date: Fri, 01 Jul 2005 12:44:26 -0700
I have been writing an applescript that will take a folder of images and
process them through some command line tools. When using the Do Shell Script
command, AS returns the error that the command cannot be found. But they are
there, because I can use them when I am in the terminal. I think it has
something to do with the way that the tools I am using interact with one
another. So what are the tools?
First is the JPEG package from the Independent JPEG Group
(http://www.ijg.org/), which includes a lossless crop and rotate tool called
"jpegtran". I don't know of an installable binary for these tools, I have
had to install them by first installing the DarwinPorts tool, then
installing the "jpeg" package through the DarwinPorts using the CL. This is
only the first part of the package.
Second is a command called Jhead
(http://www.sentex.net/~mwandel/jhead/usage.html), which extends the
functionality of jpegtran command, by allowing you to make transitions that
are based on the EXIF data that is embedded into the jpeg file from most
digital camera's.
Why this is important to me, is because I take a LOT of digital pictures all
at one time, and then I have to go through and decide which ones were not
that great and delete them. I use a program called Simple Image Browser to
do this. Since a large number of my photos are portrait (but not all) I
would spend a lot of time with my head on my shoulder looking sideways. But
there is help! Canon camera's (which is what I use) have a neato gravity
sensor in them, that allows the camera to know when it is portrait mode, and
even which end of the camera is pointing up. It writes this information to
EXIF. Unfortunately the image browser I use does not know about this
orientation tag, and thus does not auto rotate the pics for me (Picture
Viewer in 10.4 does however do this, unfortunately it is VERY slow when you
are trying to look at 100 images in a single folder.
So onto the script, I am using the example script that was on Apple's
website to process folders of items. So really only the last part I changed
which looks like this
on process_item(this_item)
do shell script "/opt/local/bin/jhead -cmd \"/opt/local/bin/jpegtran
-progressive &i &o \" -autorot -n%m-%d-%Y-%H-%M-%S " & this_item
end process_item
So you will see that the jhead tool is not like other command line tools
that pipe to other tools, and instead uses the -cmd argument to call onto
jpegtran to do it's thing (which is the -autorot argument) and I am also
having jhead rename the files according the their EXIF date and time.
So when this script runs, it always tells me that the jpegtran command can
not be found. I thought it might be something to do just with how AS was
sending the command line to the system, so I created a shell script that I
saved, and then called just the shell script, but got the same error. But
when I run the same exact command from the terminal, things work.
If I can't get these command lines to work, I might have to reinvent the
wheel and have AS read the EXIF data, and then parse it out and then send
separate commands to this two commands. I am sure it would work, but it
seems like a big pain in the ass to me. So I am turning to all of you smart
people on the list, to see if you have any ideas.
Sorry for the long winded post.
Chris Norman
Technology Manager
Kane and Finkel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden