[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Re: Photoshop/Photoscripter and glue



>I've been trying to script Photoshop/PhotoScripter with MacPerl. I
>wasn't able to get very far with the Glue approach. I had more
>success using AppleEvents::Simple, but eventually had to resort to
>MacPerl::DoAppleScript.

Photoshop and Photoscripter are what I'd call a *real* special case.
Photoshop itself has a dynamic dictionary - that's why it opens up if you
try and read the dictionary (at least with Script Editor). Script Editor
says "Hey, this dictionary might get changed when the application runs, so
I'd better not read it until the application is open". Photoscripter, of
course, does just that, it changes the dictionary. But only when the
Application is open.

I don't know what you've tried to get a glue for Photoscripter. This is
what I would recommend (although I don't have a copy myself to test it
with).

Launch Photoshop, with Photoscripter installed. Then try and make a glue
of Photoshop. That should give you the

If that doesn't work, you could try dropping Photoscripter itself onto
gluemac. You shouldn't need to do anything like change the file type to
"APPL", because gluemac doesn't care about those things.

I was able to make a glue for Photoshop/PhotoScripter without any problem. To do this, Photoshop had to be running, as you predicted.

You said you didn't get very far with glue, and ran into problems with
AppleEvent::Simple. What kind of problems? There really *shouldn't* be
any difference between the three approaches (except for things like
application time out, which again shouldn't make a difference).

I was trying to do the following:

Open an image.
Change the size and resolution.
Apply the USM filter.
Save the document in it's original file format.
Close the document.

With Glue, I was able to open the image and close it. The size and resolution are special floating point values, and I couldn't get that to work. The radius for USM is floating point, so that wouldn't work either. Saving the document needed parameters to be set, such as the file format, encoding method and so on. I never found a way to make that to work properly, although I got close.

With AppleEvents::Simple, I got everything to work, except for the floating point parameters. I was even able to make the USM filter work by supplying the radius as a string (e.g. "1.5"). Apparently, PhotoScripter coerced that into a floating point value. But there were larger problems with dimensions having units. For instance, to change the resolution, the AppleScript reads:

adjust docID changing image size to ¬
{width:$width as inches, height:$height as inches, resolution:$res as density, interpolation method:bicubic}

This results in the width, height and resolution being sent as special data types. Cal Simone, the author of PhotoScripter, wrote the following in answer to my question about the stucture of these AppleEvents:

"Essentially, unit types are doubleword (8-byte) floating point numbers
with the data type being a unit of measurement, such as 'inch', 'metr',
'cent', instead of 'doub', the same as typeFloat in Apple Events. So 3.0
as inches is identical in data to just 3.0, except for the descriptor
type which is 'inch' instead of 'doub'."

I have no idea how to accomplish this with Glue or AppleEvents::Simple. It may not be possible becasue of limitations in AEGizmos.

So I wound up using MacPerl::DoAppleScript. Becasue these Photoshop operations take a long time, the overhead of using AppleScript is not a problem. But I really hate doing it that way, and would love to use Glue if I could. Any suggestions would be appreciated.

-Bill