Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Image Events Apple Scripts

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  iChat  
Author Message
cp2

External


Since: Dec 04, 2003
Posts: 5



(Msg. 1) Posted: Fri Dec 10, 2004 4:47 pm
Post subject: Image Events Apple Scripts
Archived from groups: alt>comp>lang>applescript, others (more info?)

I pulled some sample applescripts from the Apple Web sites for
scripting the new Image Events Ap (SIPS) that comes with Panther.

I get uneven results, and I am trying to decide if it is my system
install, my poor understanding of Apple script, or expected behavoir.

If I run this script on a G4 Quicksilver 733 with 10.3.6 updated from
software update:

set this_file to choose file
try
tell application "Image Events"
launch
-- open the image file
set this_image to open this_file
-- extract the property value
copy the resolution of this_image to {xres, yres}
-- purge the open image data
close this_image
end tell
display dialog "Resolution: " & (xres as string)
on error error_message
display dialog error_message
end try

After selecting an image, it displays the error: Can't get item 1 of {};

If I run the same script on a Blue & White with 10.3.6 update from
Software update, I get the expected result: 72.0

Other properties such as File Type and bit depth are missing as well.

Any one encounter this type of problem before?

--
cp

 >> Stay informed about: Image Events Apple Scripts 
Back to top
Login to vote
Martin Crisp

External


Since: Jul 02, 2003
Posts: 74



(Msg. 2) Posted: Sun Dec 12, 2004 3:40 am
Post subject: Re: Image Events Apple Scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Sat, 11 Dec 2004 08:47:06 +1100, cp wrote
(in article ):

[snip]
 > I get uneven results, and I am trying to decide if it is my system
 > install, my poor understanding of Apple script, or expected behavoir.
 >
 > If I run this script on a G4 Quicksilver 733 with 10.3.6 updated from
 > software update:

[snip script]

 > After selecting an image, it displays the error: Can't get item 1 of {};
 >
 > If I run the same script on a Blue & White with 10.3.6 update from
 > Software update, I get the expected result: 72.0
 >
 > Other properties such as File Type and bit depth are missing as well.
 >
 > Any one encounter this type of problem before?

Works fine for me on a G4 400 10.3.6
I get the error you do for _non-image_ files, and whatever res is
in an image file.

If you're sure your files are image files, is there any consistency
in when the error strikes? (check the image details with
GraphicConverter, say)

Have Fun
Martin
--
aa #1792

Almost always SMASHed

 >> Stay informed about: Image Events Apple Scripts 
Back to top
Login to vote
Simon Slavin1

External


Since: May 16, 2004
Posts: 375



(Msg. 3) Posted: Sun Dec 12, 2004 4:51 pm
Post subject: Re: Image Events Apple Scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 10/12/2004, cp wrote in message
:

 > set this_file to choose file
 > try
 > tell application "Image Events"
 > launch
 > -- open the image file
 > set this_image to open this_file
 > -- extract the property value
 > copy the resolution of this_image to {xres, yres}
 > -- purge the open image data
 > close this_image
 > end tell
 > display dialog "Resolution: " & (xres as string)
 > on error error_message
 > display dialog error_message
 > end try
 >
 > After selecting an image, it displays the error: Can't get item 1 of {};

The offending line is this:

 > copy the resolution of this_image to {xres, yres}

I've had the same problem. It seemed to me at the time that
"Image Events" can't handle too many instructions too fast.
Although the 'open this_file' command completes, it hasn't
really opened the file, so 'resolution of this-image' doesn't
exist.

My AppleScript was part of an AppleScript Studio program so
I replaced the equivalent part of my program with this:

    set theImage to load image fileName
    set {theWidth, theHeight} to call method "size" of theImage
[There would be a 'delete theImage' command here.]

But I don't know if those commands are available to you in a
standard AppleScript.

Simon.
--
Using pre-release version of newsreader.
Please tell me if it does weird things.
 >> Stay informed about: Image Events Apple Scripts 
Back to top
Login to vote
Jerry Kindall

External


Since: Jul 09, 2003
Posts: 560



(Msg. 4) Posted: Sun Dec 12, 2004 6:05 pm
Post subject: Re: Image Events Apple Scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article , Simon Slavin
wrote:

 > On 10/12/2004, cp wrote in message

 >
  > > set this_file to choose file
  > > try
  > > tell application "Image Events"
  > > launch
  > > -- open the image file
  > > set this_image to open this_file
  > > -- extract the property value
  > > copy the resolution of this_image to {xres, yres}
  > > -- purge the open image data
  > > close this_image
  > > end tell
  > > display dialog "Resolution: " & (xres as string)
  > > on error error_message
  > > display dialog error_message
  > > end try
  > >
  > > After selecting an image, it displays the error: Can't get item 1 of {};
 >
 > The offending line is this:
 >
  > > copy the resolution of this_image to {xres, yres}
 >
 > I've had the same problem. It seemed to me at the time that
 > "Image Events" can't handle too many instructions too fast.
 > Although the 'open this_file' command completes, it hasn't
 > really opened the file, so 'resolution of this-image' doesn't
 > exist.

Try this:

set this_file to choose file
try
tell application "Image Events"
-- open the image file
set this_image to open this_file
-- extract the property value
repeat until exists resolution of this_image
delay 1
end repeat
copy the resolution of this_image to {xres, yres}
-- purge the open image data
close this_image
end tell
display dialog "Resolution: " & (xres as string)
on error error_message
display dialog error_message
end try

The delay isn't needed on my dual 2.5, so I don't know if this actually
solves the problem.

--
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>

Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
 >> Stay informed about: Image Events Apple Scripts 
Back to top
Login to vote
cp2

External


Since: Dec 04, 2003
Posts: 5



(Msg. 5) Posted: Mon Dec 13, 2004 9:48 am
Post subject: Re: Image Events Apple Scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article , Jerry
Kindall wrote:

 > Try this:
 >
 > set this_file to choose file
 > try
 > tell application "Image Events"
 > -- open the image file
 > set this_image to open this_file
 > -- extract the property value
 > repeat until exists resolution of this_image
 > delay 1
 > end repeat
 > copy the resolution of this_image to {xres, yres}
 > -- purge the open image data
 > close this_image
 > end tell
 > display dialog "Resolution: " & (xres as string)
 > on error error_message
 > display dialog error_message
 > end try
 >
 > The delay isn't needed on my dual 2.5, so I don't know if this actually
 > solves the problem.

No, sadly it does not, but thanks for the suggestion. The loop will
simply repeat without setting the resolution.

It seems to be about 50%-50% whether this script will run or not
(tested on 6 macs and from users reports on the News Group and mailing
list). I'm not able to isolate what might be the cause.

Is there another, more stable solution from getting the resolution,
file type, etc., and scalling on the fly from AppleScript?

--
cp
 >> Stay informed about: Image Events Apple Scripts 
Back to top
Login to vote
Jerry Kindall

External


Since: Jul 09, 2003
Posts: 560



(Msg. 6) Posted: Mon Dec 13, 2004 8:20 pm
Post subject: Re: Image Events Apple Scripts [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article , cp
wrote:



 >
  > > Try this:
  > >
  > > set this_file to choose file
  > > try
  > > tell application "Image Events"
  > > -- open the image file
  > > set this_image to open this_file
  > > -- extract the property value
  > > repeat until exists resolution of this_image
  > > delay 1
  > > end repeat
  > > copy the resolution of this_image to {xres, yres}
  > > -- purge the open image data
  > > close this_image
  > > end tell
  > > display dialog "Resolution: " & (xres as string)
  > > on error error_message
  > > display dialog error_message
  > > end try
  > >
  > > The delay isn't needed on my dual 2.5, so I don't know if this actually
  > > solves the problem.
 >
 > No, sadly it does not, but thanks for the suggestion. The loop will
 > simply repeat without setting the resolution.
 >
 > It seems to be about 50%-50% whether this script will run or not
 > (tested on 6 macs and from users reports on the News Group and mailing
 > list). I'm not able to isolate what might be the cause.

Does it sometimes work on a machine, and sometimes not? If so, you
could probably retry the whole thing from the top if you get an error.

If it consistently doesn't work on a given Mac then that's not a good
solution.

 > Is there another, more stable solution from getting the resolution,
 > file type, etc., and scalling on the fly from AppleScript?

Well, you could install ImageMagick, a UNIX command line tool for
manipulating graphics, and invoke it using "do shell script." Or you
could use some other scriptable application already on your machine
(GraphicConverter, Photoshop, etc.) to do the work.

--
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>

Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
 >> Stay informed about: Image Events Apple Scripts 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Property List and Apple scripts - I was wondering if it possible to drive the Property List Editor with Applescript ? I would like to create a new property List and add new items ... Stephane

run several scripts one after the other - I have a folder storing several maintenance script and I call them from another script: // tell app "finder" repeat with le_script in every item of folder le_dossier_de_scripts run script (le_script as alias) end repeat end tell // the problem...

Scripts Menu Shortcuts - Is there any way to set Keyboard Shortcuts for the scripts menu? Thanks.

Safari Scripts - GUI scripting beta? - http://www.apple.com/applescript/safari/ has a collection of scripts for Safari, many of which require the installation of a beta of GUI scripting. (other places linked to this page have other iApps mentioning User Interface scripting, but call it UI..

Looking for scripts for Akai's MESA program - Does anyone know of any? Regards, Nick. -- Check out my Guitar Tuition site http://www.fretbored.co.uk http://www.cubasics.com, making Cubase simple.
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]