Total newbie here…I’m thinking about playing with AppleScript. One common problem that I have is that I need to rotate pictures more than 90 degrees. I’m an iPhoto novice, but in my limited usage it seems that I have to click the rotate button 2, 3, or 4 times to rotate the image to its final state.
I would like to write an AppleScript that would include a GUI that would prompt the user for how many degrees to rotate and in which direction (clockwise or counter clockwise).
I looked at the iPhoto script docs and it doesn’t seem that I can rotate an image. Seems like only file type operations were available.
I was hoping that AppleScript would be similar to Microsoft VBA where I can “record” actions in an application and then modify the generated code.
I have read that Panther now provides some image manipulation on an OS level. Is that correct?
So, can I use iPhoto-only functions to do this? If not, can I use a combo of iPhoto and Panther functions? But I guess then I’d have to find the exact file of a photo in the iPhoto library…Is that easy to do?
display dialog "what angle would you like" default answer "-90"
set the_angle to the text returned of the result
set the_file to choose file
tell application "Image Capture Scripting"
set this_image to open the_file
rotate this_image to angle (the_angle as number)
save this_image in the_file
close this_image
end tell
of course you may need some error handling
but this could do the trick
– this sub-routine processes folders on [color=green]process_folder/color tellapplication “Finder” to ¬ setthese_itemstoitemsoffolderthis_folderasalias list repeatwithifrom 1 tothecountofthese_items setthis_itemtoitemiofthese_items settheitem_infotoinfo forthis_item iffolderoftheitem_infoistruethen
[color=green]process_folder/color elseif (aliasoftheitem_infoisfalse) then my [color=green]process_item/color endif endrepeat endprocess_folder
– this sub-routine rotates the files on [color=green]process_item/color
(*[color=olive]--============ use these to control each file's angle individually=========
set the_info to info for this_item
display dialog “What angle would you like for file” & return & ((name of the_info) as text) & return & “use - for counter clockwise” default answer “-90”
set the_angle to the text returned of the result
–========== end individual angle control=============
[/color]*)
Greetings,
The discussion above is along similar lines to what I was considering how to address. With my digital camera (Olympus C-750 UltraZoom) you can rotate images during playback on the camera. When these images are imported by Image Capture, they are in their original orientation, not rotated. However, the EXIF data in the picture is updated by the camera, to say:
Orientation: Rotate 90
I manually go through when importing images and rotate them in Image Capture anyway, but was thinking it would be excellent if Image Capture automatically rotated any images that had this EXIF data. Looking at Image Capture more I’ve realised that while you can set it to run an Applescript after downloading images, I would have already rotated them manually by then anyway.
Hmm. I think what I want should be included in Image Capture automatically, and probably can’t be fixed by an AppleScript. Any ideas though? And, is this changed in Panther? (Haven’t yet upgraded, though going to soon!)
sigamy,
Unless you frequently take pics with your camera upside down, you really should never need to click the rotate button in iPhoto more than once. (Even if you do take pics upside down, you would only need to click rotate twice!) The direction of rotation can be changed by holding down the option key. You can also set the default rotation direction of this button in iPhoto’s prefs. So if you usually hold your camera with the left side down, you can set the default rotation direction to suit that. If you have a photo that you need to rotate the direction opposite of your default direction, just hold the option key and click it. BTW, clicking rotate 4 times results in the photo being in it’s original orientation.
HTH.
You mentioned that you camera inserts exif information which includes the rotation of the camera when the picture was taken. I am in the processing of finalizing the features for version 2 of iMagine which will be due out in February. I have greatly extended the exif functionality for reading and writing exif information for AppleScripters but I haven’t got any images which have the orientation specified in the exif information. I would greatly appreciate it if you could supply me with an image file so that I can add orientation as one of the exif parameters that I can read and write.