Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to do photos in AppleScript?



On Jul 27, 2007, at 3:14 PM, Christiaan Hofman wrote:

On 27 Jul 2007, at 11:54 PM, Daniel Jalkut wrote:

On Jul 27, 2007, at 5:29 PM, Mike Zornek wrote:

What should the type be?

Are there any example Cocoa apps out there that have image attributes?

You've run up against the frustration of where AppleScript's types end and custom app-defined types begin.


If you look inside iChat's dictionary, you find that it defines TIFF Picture as essentially backed up by "NSData".

Not sure what this means for how (or if) scripters can usefully manipulate the TIFF Picture with data from outside of the app (e.g. from a disk file).

Generally I think what you would do is expose a class like "TIFF Picture" such that it included a property like "data path" or something, so users could do something like "make new TIFF Picture with properties {data path:myPictureFilePath}".

I'm pretty rough on this stuff myself, though.

I haven't tried this myself, but I guess you need to declare the TIFF Picture type as a value type, declare it in the .sdef as something like:


<value-type name="TIFF Picture" code="TIFF">
  <cocoa class="NSData" name="Image"/>
</value-type>

(I'm not sure the TIFF code, it must be consistent with other occurrences of this type though). I think that if you have an accessor for the TIFF data of the image this could work.

That works just fine -- in fact, it's what iChat does these days -- but that wasn't really Daniel's question. Given that declaration, you can copy images around within iChat -- say, from one buddy to another -- but setting the image to an image from some random file is, er, harder. The basic problem is that AppleScript doesn't have any real "image" value type of its own. You could probably fake it by reading from a TIFF file "as «class TIFF»", which should give you a data blob value of a sort that iChat will accept. (Haven't tried it myself, though, and it's not exactly what you'd call obvious in any case.)



--Chris Nebel AppleScript Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/email@hidden

This email sent to email@hidden
References: 
 >Re: How to do photos in AppleScript? (From: Mike Zornek <email@hidden>)
 >Re: How to do photos in AppleScript? (From: Daniel Jalkut <email@hidden>)
 >Re: How to do photos in AppleScript? (From: Christiaan Hofman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.