Runs in Script Editor, not as droplet
Runs in Script Editor, not as droplet
- Subject: Runs in Script Editor, not as droplet
- From: "Marc K. Myers" <email@hidden>
- Date: Mon, 13 Aug 2001 10:39:53 -0400
- Organization: [very little]
I wrote the following script to create low-res copies of hi-res images
from a digital camera. It runs perfectly from Script Editor but errors
out when run as a droplet. The error message says that the variable
theImage was not defined. When I click the "Edit" button on the error
dialog, the first instance of theImage after it's defined is
highlighted. I put in the display dialog to see what the class of the
variable was. Under Script Editor it tells me that the class is
"picture". As a droplet (with stop log and start log commands commented
out) it errors out on the instance of the variable in the display dialog
statement. Does anyone have any idea what's going on here?
on run
open ({choose folder})
end run
on open (theItems)
if (count of theItems) > 1 then
display dialog "This script is set up to process a single folder
of JPEG images" buttons {"OK"} default button 1 with icon stop
error number -128
end if
set theFldr to (contents of item 1 of theItems)
if character -1 of (theFldr as text) is not ":" then
display dialog "This script is set up to process a single folder
of JPEG images" buttons {"OK"} default button 1 with icon stop
error number -128
end if
tell application "Finder"
set fileCnt to count (files of theFldr whose file type is "JPEG")
if fileCnt < 1 then
display dialog "No JPEG files were found in the input"
buttons {"OK"} default button 1 with icon stop
error number -128
else if fileCnt > 1 then
set fileList to (files of theFldr whose file type is "JPEG")
as alias list
else
set fileList to (files of theFldr whose file type is "JPEG")
as alias as list
end if
set destFldr to (choose folder with prompt "Choose the
destination folder:")
open destFldr
set view of destFldr to 2
end tell
set convCnt to 0
repeat with aFile in fileList
set theFile to contents of aFile
set AppleScript's text item delimiters to {":"}
set fileName to text item -1 of (theFile as text)
set AppleScript's text item delimiters to {""}
stop log
set theImage to the image from theFile -- defined here
start log
display dialog (class of theImage) as text -- error here
stop log
set theImage to scale image theImage to {0, 0, 640, 480}
store image theImage in ((destFldr as text) & fileName) [optn-L]
as "JPEG" with percent quality 75
start log
apply catalog info {file creator:"GKON"} to alias ((destFldr as
text) & fileName)
set convCnt to convCnt + 1
end repeat
if convCnt > 1 then
set theText to (convCnt as text) & " images were converted"
else
set theText to "One image was converted"
end if
say "Conversion completed" using "Fred"
say theText using "Fred"
activate
display dialog theText buttons {"OK"} default button 1 [optn-L]
with icon note giving up after 15
end open
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[8/13/01 10:38:04 AM]