I have been getting the following error intermitently.
Can anyone clarify please.
iMagine Photo got an error: Connection is invalid. (-609)
It seems to be associated with the quitting of the Imagine Photo application from within a Studio App.
I am loading Imagine Photo ready for use from an open menu handler to ensure its immediate availability when required and then disposing it from a close menu handler so it does not stay open when the studio app has closed.
Do you know if your handler to tell iMagine Photo to quit could be called a couple of times. That message usually occurs when an application is already quitting and can’t deal with any more apple events. If the application has fully quit then it will be restarted so that it can be sent the quit message.
You could choose to setup iMagine Photo to run as a background only application with a quit delay. This way your users wont notice it running and after a period of time without any apple events being sent to it, it will quit by itself. It wont quit if there are any open files or graphics documents.
See the applescript dictionary for the application class in the Standard Suite and/or see about 2/3 of the way down the following page:
I understand what you are saying nad have tried the quit delay as suggested and it does work, however, when I have a problem like this it bugs me until I either understand and succeeed or lose interest.
Two scripts that show where I am having the problem. Hope you can see an obvious problem. This is the only place in my application where qutting iMagine Photo happens. I have also tried it in a should quit handler and a will quit handler with the same error.
Regards
tellboy
on CloseLibrary()
if pLibraryOpen of PropLib is equal to "true" then
delete image of image view "ImageView" of window "ImageViewer"
set pImagesLoaded of PropLib to 0
end if
set content of text field "CurrentImage" of window "ImageViewer" to ""
set content of text field "ImageCount" of window "ImageViewer" to ""
SetMenusClosed() of MenuLib
WriteFile() of PropLib
ResetProperties() of PropLib
ClearThumbs() of ThumbLib
tell application "iMagine Photo" to quit
end CloseLibrary
on QuitApp()
CloseLibrary()
quit
end QuitApp
Can you do a temporary hack for me to test if your QuitApp handler is being called twice, I have had some unexpected results with handlers like the “on quit” handler in AppleScript studio applications.
Something like this near the begginging of the script file.
property hasQuitAppBeenCalled : false
and then modify your QuitApp() handler like so
on QuitApp()
if hasQuitAppBeenCalled is false then
set hasQuitAppBeenCalled to true
CloseLibrary()
quit
else
display dialog "QuitApp() has been called twice"
end
end QuitApp
Then leave that change in for a while and see if the message ever pops up.
In ScriptEditor everything works just fine if I do this:
tell application "iMagine Photo"
launch
quit
quit
end tell
But using Smile, I get the connection is invalid message everytime when running the following from the worksheet and made “iMagine Photo” the target application:
Since making the alteration below I have not got the error.
Don’t understand why but it seems to work.
Regards
tellboy
on CloseLibrary()
if pLibraryOpen of PropLib is equal to "true" then
delete image of image view "ImageView" of window "ImageViewer"
set pImagesLoaded of PropLib to 0
end if
set content of text field "CurrentImage" of window "ImageViewer" to ""
set content of text field "ImageCount" of window "ImageViewer" to ""
SetMenusClosed() of MenuLib
WriteFile() of PropLib
ResetProperties() of PropLib
ClearThumbs() of ThumbLib
--tell application "iMagine Photo" to quit
end CloseLibrary
(*
on QuitApp()
CloseLibrary()
quit
end QuitApp
*)
on QuitApp()
tell application "iMagine Photo" to quit
if hasQuitAppBeenCalled is false then
set hasQuitAppBeenCalled to true
CloseLibrary()
quit
else
display dialog "QuitApp() has been called twice"
end if
end QuitApp
That’s interesting. I wonder if it is because the quit event for the AppleScript Studio app has only been called once.
I can’t say I can help much more I really would only be guessing in terms of why you are (not) getting the “Connection is invalid” message. It might mean (but I don’t know) that your AppleScript studio application has closed down far enough that it can no longer handle events even replies anymore so when iMagine Photo replies (ok) to the quit request there is no longer an application for that reply to be sent. But this still doesn’t help in terms of your last little script.
I do have two questions though
Why is your on quit handler being called twice?
Do you need to call quit when you are in the quit handler?
Also I would like to know what you are using iMagine Photo for?
I have been scripting an Image Viewer application in SuperCard which is my primary scripting environment.
I have hit a wall in that there are no facilities within the current SuperCard environment for importing image thumbnails into a matrix or table. A workround is possible by creating a series of thumbs on a page and navigating via buttons.
I started exploring AppleScript Studio as an alternative and have not found the scripting to be as strightforward as SuperCard but AppleScript Studio appears to have access to the majority if not all of the Cocoa interface elements.
I have managed thus far to :
view images singly in a window and browse those via buttons
view thumbnail images in a scrolling matrix
view images at full size in a scrolling window
view images in a slide show full screen
I have noticed a significant speed difference in the loading of images beween SuperCard and AppleScript Studio.
AppleScript Studio is apprximately 20% faster by my crude timing method in traversing a list of say 70 images.
I have in SuperCard scaled/flipped/rotated images via the shell using Apples SIPS system and i think I tried a JPEGTRAN and have obtained the EXIF data of the image using a shell program called ExifInfo. I have done the same in AppleScript Studio but noted your iMagine Photo programme which seems to integrate these areas plus provides additional facilities that may be useful.
Using iMagine Photo from within AppleScript Studio i have currently implemented rotate and flip. Scaled and crop to be implemented shortly.
With regard to the transformation matrix I implemented the horizontal flip as detailed in the documentation and vertical by trial and error because I could not see any documentation on how to use the transformation matrix. Could you point me to some explanantion of this facility.
I have not tried implementing the reading of EXIF data which I will be doing shortly.
I decided to open imagine Photo on reading in the thumbnails as there was a slightly noticeable delay if you opened imagine at the point of doing a transformation which made its implementation slightly slower than SIPS. In actual practice there does not appear to be any speed of implementation difference between SIPS and iMagine.
I have been looking for a method of implementing Core Image functions from within SuperCard and/or AppleScript Studio but without success. I do not possess the skills to create Objective C routines myself. These do not appear to be available from iMagine Photo?
This was just a few notes to my use of iMagine within the context of my experiences with SuperCard and AppleScript Studio.
I always like to know how iMagine Photo gets used.
As to the tranformation matrix. Describing how it works will depend on whether you have done advanced maths in your last year at school or at least did first year maths at uni.
When you do rotations, scalings or translations or any combination of those the transformation matrix keeps the record of what has been done and the order it was done. By setting the scaling, rotation and (top left point) properties of the graphic importer and then get the transformation matrix and you can see how the transformation matrix changes as you make these changes.
As to core image, what sort of things would you like to be able to do. iMagine Photo is totally dependent on Quicktime which takes advantage of core image functionality when it can, certain operations will stop core image from being used but Quicktime is not too bad at optimizing an alternative. There are a number of image filters that iMagine Photo can apply like blur, sharpen, color balance etc.