Re: Save in Image Events
Re: Save in Image Events
- Subject: Re: Save in Image Events
- From: Luther Fuller <email@hidden>
- Date: Wed, 14 Dec 2005 13:59:47 -0600
Title: Re: Save in Image Events
Both Yvan KOENIG and Jay Louvion suggested
that 'save' needs a file reference not just a reference to a folder. I
used a folder reference simply because it worked. But their comments
do suggest a work-around that's much simpler than what I had in
mind.
instead of writing ...
save theImage as TIFF in
destFolder
I wrote ...
save theImage as
TIFF in file (fileName & ".tiff") of
destFolder
This forces the new file to have the
correct extension even if the extension is missing from the original
file. (BTW, I was not able to get 'save theImage as QuickTime Image
...' to work at all. Don't know why.) Here's the complete
script:
on open dropList
"Choose a destination for the converted files
..."
choose folder with prompt the result
set destFolder to the result
try
set newType to my
chooseNewType()
on error
return
end try
tell application "Image Events"
launch
repeat with dropItem in
dropList
set
theImage to open dropItem
set
fileName to my getFileName(dropItem)
if
newType is "BMP" then
save theImage as BMP in file
(fileName & ".bmp") of destFolder
else if newType is "JPEG" then
save theImage as JPEG in file
(fileName & ".jpg") of destFolder
else if newType is "JPEG2" then
save theImage as JPEG2 in file
(fileName & ".jp2") of destFolder
else if newType is "PICT" then
save theImage as PICT in file
(fileName & ".pict") of destFolder
else if newType is "PNG" then
save theImage as PNG in file
(fileName & ".png") of destFolder
else if newType is "PSD" then
save theImage as PSD in file
(fileName & ".psd") of destFolder
else if newType is "TIFF" then
save theImage as TIFF in file
(fileName & ".tiff") of destFolder
end
if
close theImage
end repeat
end tell
end open ------------------------------------------
on getFileName(fileAlias)
set AppleScript's text item delimiters to
{"."}
tell application "Finder" to (name of
fileAlias) as text
(text items of the result) as list
return (item 1 of the result) as text
end getFileName ----------------------------------
on chooseNewType()
{"BMP", "JPEG",
"JPEG2", "PICT", "PNG", "PSD",
"TIFF"}
choose from list the result with prompt
"Convert to ..."
if class of the result is list then
return item 1 of the
result
end if
error
end chooseNewType ----------------------------------
This script WILL convert .pdf to anything
you choose, BUT only the first page is converted.
_______________________________________________
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