Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > image events applescript

image events applescript
Thread Tools
Junior Member
Join Date: May 2002
Status: Offline
Reply With Quote
Nov 17, 2003, 07:30 AM
 
Why doesnt this do anything?

set this_file to choose file
set target_path to "newimage.jpg"
tell application "Image Events"
launch
set this_image to open this_file
save this_image as JPEG in target_path with icon
close this_image
end tell
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Nov 17, 2003, 09:26 AM
 
You identify a fiile to manipulate in the first line, creating a reference (alias) to the path to the file. In the second line, you create a string witha variable name of newimage.jpg. This not not a reference to a file or a path.

You used <http://www.apple.com/applescript/imageevents/03.html> as a template. I would delete your second line and add these lines there-
Code:
set target_folder to choose folder as string set target_file to (target_folder & "newimage.jpg" as alias.)
Your new file needs to be a reference, so the name needs to be a path reference that refers to or points to the file. The second line suggested creates an filepath alias which is a reference.

HTH
Craig
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Nov 17, 2003, 06:32 PM
 
That probably won't work. You can only create an "alias" reference to an existing file, not to one that you've not yet created. The "file" class has no such restriction, and is usually just as valid asa file reference. So, this is probably more likely to work (but untested):
Code:
set target_file to file (target_folder & "newimage.jpg" as string)
Rick Roe
icons.cx | weblog
     
patzoul  (op)
Junior Member
Join Date: May 2002
Status: Offline
Reply With Quote
Nov 19, 2003, 05:41 AM
 
I am now trying the script below but getting the following error:
NSCannotCreateScriptCommandError

set this_file to choose file
set target_folder to (choose folder) as string
set target_file to file (target_folder & "newimage.jpg" as string)
tell application "Image Events"
launch
set this_image to open this_file
save this_image as JPEG in target_file with icon
close this_image
end tell
     
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
Feb 20, 2005, 11:42 AM
 
Originally posted by patzoul:
I am now trying the script below but getting the following error:
NSCannotCreateScriptCommandError

set this_file to choose file
set target_folder to (choose folder) as string
set target_file to file (target_folder & "newimage.jpg" as string)
tell application "Image Events"
launch
set this_image to open this_file
save this_image as JPEG in target_file with icon
close this_image
end tell
What happens if you change:
Code:
save this_image as JPEG in target_file with icon
to this:
Code:
save this_image as JPEG in file target_file with icon
by inserting the word "file"?
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:25 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2