Team LiB   Previous Section   Next Section
ColorSync

Syntax

tell app "Colorsync Extension"

   (* embed ICC profile referred to by the variable profFile in the image 

file represented by variable jpegImage *)

   embed jpegImage with source profFile

end tell

The following commands and classes derive from ColorSync Extension Version 3.0, which is installed with Mac OS 9.

Dictionary commands

run

This opens the ColorSync application as an invisible or faceless background application (i.e., one that doesn't have a graphical user interface).

quit

This quits the ColorSync Extension application.

open object reference

This opens an image to inspect its profile (see the Examples section). This command returns a reference to the opened image.

save object reference

This command saves an image file with a new ICC profile, for instance.

in alias

This provides an alias file path for saving the image file.

close object reference

This closes an image file, as in:

close imgFile saving in alias "Macintosh HD:Desktop¬ Folder:cowgirl2.jpg"
saving yes/no

If you have embedded a new ICC profile in an image file, you probably would want to:

close imgFile saving yes

As you might have guessed, this code saves the image file before the script closes it; you can close the file without a save with the saving no parameter.

saving in alias

This saves an open object in an alias file before closing it:

close imgFile saving in¬

(alias "macintosh hd:desktop folder:cowgirl.jpg")
embed alias

This command embeds an image with an ICC profile from the System Folder:ColorSync Profiles folder, as in:

embed imgFile with source profile "Apple Studio Display"

with source profile object

This required labeled parameter identifies the ICC profile object you want to embed in the file. You can either use a specific profile, as in:

profile "Apple Studio Display"

or a variable that refers to a profile object. See the profile class in this chapter.

matching with constant

Follow the matching with optional labeled parameter with one of these constants: perceptual intent/relative colorimetric intent/saturation intent/absolute colorimetric intent. These terms specify the "rendering intent," which affects how the colors of the image with its embedded profile are rendered on the destination device, such as a monitor.

using quality normal /draft / best

Optionally specify another parameter for rendering the image with one of the three constants.

saving into file specification

If you include this optional labeled parameter with a folder name, then a new file is created in that folder with the same name as the original file. The original file is modified if this labeled parameter is not used. This example asks the user for a file in which to embed the "Apple Studio Display" ICC profile, then saves it in the folder of the user's choice:

set nfile to (choose file of type {"JPEG", "TIFF", "PICT"})

set folSpec to (choose folder)

tell application "ColorSync Extension"

   embed nfile with source profile "Apple Studio Display"¬

   saving  into folSpec

end tell
replacing boolean

This is an optional true/false value that specifies the replacement of an existing file with the newly embedded file.

unembed alias

This command removes any embedded ICC profiles from an image specified in the alias parameter.

saving into file specification

You can save the file, now with its ICC profiles removed, to a different file than the original. The user may choose the new destination file with the choose file scripting addition. Or, if the user chooses a folder instead in response to the choose folder osax, then an image file with the same name as the original file will be saved into the folder (but this new file is sans ICC profiles). This is demonstrated in the prior example, which uses the embed command that also has a saving into labeled parameter.

replacing boolean

This is a true/false value that specifies the replacement of an existing file with the newly unembedded file.

match alias

Use this command to match an image with a destination profile, such as a profile for a certain printer. You can let the user choose a file for this command with the choose file scripting addition. See the Examples section to learn how to choose both the image file and the ICC profile before initiating the match command.

from source profile object

This includes an optional source profile for the match, as in:

from source theProf (* theProf is a variable containing a profile object *)

to destination profile object

This specifies the destination profile or the profile associated with the device on which the image will be displayed. See the Examples section for a demonstration of this labeled parameter's usage.

matching with constant

This labeled parameter takes one of the "rendering intent" constants: perceptual intent/relative colorimetric intent/saturation intent/absolute colorimetric intent. This setting affects how the colors of the image are rendered on the destination devices, such as monitors or printers.

using quality normal /draft / best

Specify the optional match quality with one of these three constants, as in:

using quality best

saving into file specification

You can use the choose folder or choose file scripting additions to provide this labeled parameter with a file spec. If you use choose folder, then the matched image file is saved with the original file's name to the folder the user specifies.

replacing boolean

This is an optional true/false value indicating whether to replace the existing image file. For example:

set nfile to (choose file of type {"JPEG", "TIFF", "PICT"})

(* get the list of profiles from ColorSync Profiles folder *)

set pfol to list folder¬

"macintosh hd:system folder:colorsync profiles"

set prof to choose from list pfol¬

without multiple selections allowed

tell application "ColorSync Extension"

   set theProf to (profile (item 1 of prof))

   match nfile to destination theProf

end tell
proof alias

This command allows you to proof an image or preview the printed results of an image on the system's display without outputting the image to the printer.

from source profile object

Specify an optional source profile for the match. See the profile class in this chapter.

to destination profile object

This is a required labeled parameter specifying the destination profile, such as a printer's ICC profile. See the profile class.

matching with constant

This optional labeled parameter takes one of the rendering intent constants: perceptual intent/relative colorimetric intent/saturation intent/absolute colorimetric intent. matching with specifies the rendering intent for matching between the source and destination profiles. This setting affects how the colors of the image are rendered on the destination devices, such as monitors or printers.

onto proof profile object

This is a required parameter that references the proof profile for the color match. See the profile class description in this chapter for more information on profile objects.

proofing with constant

This optional labeled parameter takes one of the rendering intent constants. proofing with specifies the rendering intent for matching colors between the destination and proof profiles. The rendering-intent setting affects how the colors of the image are rendered on the destination devices, such as monitors or printers.

using quality normal /draft / best

This is an optional parameter corresponding to the match quality, as in:

using quality normal

replacing boolean

This is an optional true/false value indicating whether to replace the existing image file.

match link alias

Match a file with a "device link profile," a series of profiles corresponding to a specific configuration of devices.

through link profile object

Use this required labeled parameter to identify the device link profile with a reference to a profile object, such as:

match link imgFile through link theProf (* theProf contains the profile object *)

matching with constant

This optional labeled parameter takes one of the rendering intent constants. This setting affects how the colors of the image are rendered on the destination device.

using quality normal /draft / best

This is an optional labeled parameter you follow with one of the three constants.

saving into file specification

If you include this optional labeled parameter with a folder name, then a new file is created in that folder with the same name as the original file. The original file is modified if this labeled parameter is not used.

replacing boolean

This is an optional true/false value indicating whether to replace the existing image file.

Dictionary classes

application

The application class represents the ColorSync Extension app. It has numerous properties and contains three elements: profile, image, and display (each of these classes is described elsewhere in this chapter). For example, you can get a reference to the monitor's default ICC profile with code such as the following:

tell app "ColorSync Extension" to set monProf to (display profile¬

of  display 1)

This code first gets a reference to one of the ColorSync application's display elements (i.e., display 1), which will be display 1 if you are deprived like me and have only one monitor connected to your computer. It then sets a monProf variable to the display profile property of the display object. This property is itself a profile object. The value of monProf could be:

profile "Generic RGB Profile"

Every one of the properties is settable (not read-only) except for the profile folder.

The following are application elements:

profile

This is a profile type. You can get a reference or set a variable to one of the application class' profiles by using a numerical index:

tell application "ColorSync Extension" to get profile 1

See the profile class description.

image

ColorSync Extension has image elements if a script uses the open command to open a JPG, PICT, or TIFF file, for instance. These open images can be identified by their index, as in:

get image 1

This code in turn might return a value such as:

image "kayak.JPG" of application "ColorSync

Extension"

See the image class description.

display

The application's display objects represent the monitor(s) you have connected to your computer. See the display class description.

The following are application properties:

system profile location (alias)

This property returns an alias reference to the file that contains the system profile, as in:

file "Macintosh HD:System Folder:ColorSync Profiles:Generic¬

RGB Profile"

The profiles all live in the System Folder:ColorSync Profiles folder.

default RGB profile location (alias)

The return value for this property is the file that contains the default RGB profile. Use code such as:

tell application "ColorSync Extension" to set defRGBpath to¬

   default RGB profile location

default CMYK profile location (alias)

The return value for this property is the file that contains the default CMYK profile. All of these profiles live in the System Folder:ColorSync Profiles folder.

default Lab profile location (alias)

The return value for this property is the file that contains the default Lab profile. The return value might look like:

file "Macintosh HD:System Folder:ColorSync Profiles:" &¬

"Generic Lab Profile"

default XYZ profile location (alias)

The return value for this property is the file that contains the default XYZ profile.

default Gray profile location (alias)

The return value for this property is the file that contains the default Gray profile. Like all other profile files, it is located in the System Folder:ColorSync Profiles folder.

system profile (profile object)

Unlike the "location" properties, which return alias types involving file pathnames, these properties return the various ICC profiles as profile objects. See the profile class description.

default RGB profile (profile object)

This property returns the default RGB profile as a profile object. See the profile class description for information on the profile object's properties. Use code such as:

tell app "ColorSync Extension" to set defRGB to¬

default RGB profile

default CMYK profile (profile object)

This property returns the default CMYK profile as a profile object. See the profile class description.

default Lab profile (profile object)

This property returns the default Lab profile as a profile object. See the profile class description.

default XYZ profile (profile object)

This property returns the default XYZ profile as a profile object. See the profile class description.

default Gray profile (profile object)

This property returns the default Gray profile as a profile object. See the profile class description.

preferred CMM (automatic constant or other type)

You can get or set this property; it returns the constant automatic or another Color Match Method like Apple CMM or Heidelberg CMM (this method can also be set in the ColorSync control panel).

profile folder (alias, read-only)

This property returns a reference to the System folder:ColorSync Profiles folder.

quit delay (immediate /default /never or integer)

This property specifies how long the application will idle (await another command) before quitting. It can be either one of the three constants or an integer representing the number of seconds before the idling app will quit. For example, if you:

set quit delay to 60

the application will idle for 60 seconds and, if you do not send it any Apple events, it will then quit.

profile

This class represents a ColorSync ICC profile object. Once you have stored a profile object in a variable, then you can access its properties and/or set some of them. The Example section at the end of this chapter gets and displays a bunch of the props for a JPEG image's embedded profile.

size (integer; read-only)

This is the size of the profile in bytes.

preferred CMM (type class)

This is the profile's Color Match Method (e.g., Apple CMM).

version (international text)

This property returns the version as a string of the profile.

device class (constant; read-only)

This property returns any of the following constants: monitor/input/ output/link /abstract/colorspace/named.

color space (constant; read-only)

color space, an indication of whether the profile represents the RGB, CMYK, or gray color space, returns any of the following constants: RGB/ CMYK /Lab/XYZ/Gray/Five channel/Six channel/Seven channel/Eight channel/Five color/Six color/Seven color/Eight color/Named.

connection space (Lab / XYZ; read-only)

If it has a connection-space value, this property returns one of two constants.

creation date (date)

This returns the profile's creation date as a date object, such as:

date "Tuesday, February 18, 1997 10:56:57 AM"

platform (property type)

This property is returned as a four-character type such as 'APPL'.

quality (normal /draft / best)

A profile's quality is one of these three constants.

device manufacturer (property type)

If the profile does not represent a device such as a printer or monitor then this returns none. Otherwise, a profile such as "HP ScanJet IICX/T" returns a value such as "HP."

device model (integer)

This property returns an integer such as a serial number.

rendering intent (constant)

This returns one of the following constants: perceptual intent/relative colorimetric intent/saturation intent/absolute colorimetric intent.

creator (property type)

This property returns a creator type or code such as "KODA" for the profile "3M Matchprint Euroscale."

name (international text)

This returns the text name of the profile.

location (alias)

This property returns an alias or file path to the profile.

image

The image object has one or more embedded profile objects and three different properties, all of them read-only (not settable). You can extract property values from images after they have been opened by ColorSync Extension.

The following are image elements:

profile (profile object)

This is an object representing an embedded ICC profile. See theprofile class.

The following are image properties:

color space (constant; read-only)

This returns one of the following constants: RGB/CMYK/Lab/XYZ/Gray/Five channel/Six channel/Seven channel/Eight channel/Five color/Six color/Seven color/Eight color/Named.

name (international text; read-only)

This property is the text name of the image.

location (alias; read-only)

This property returns the image's file path location on the computer:

set img to (choose file of type {"JPEG", "TIFF", "PICT"})

tell application "ColorSync Extension"

   set imgfile to (open img)

   set imginfo to imgfile's name & " : " &¬

   imgfile's color space & return & imgfile's location

end tell

display dialog imginfo
display

This object represents a monitor connected to the computer. For example, if you have one monitor, you can access this object with code such as:

tell app "ColorSync Extension" to get display 1

number (integer)

This returns the index number of the display as in:

display 1

name (international text)

This property returns the text name of the monitor.

display profile (profile object)

This returns the ICC profile associated with the display as a profile object.

Examples

tell application "ColorSync Extension"

   (* open a jpeg image and display a bunch of the properties for its embedded ICC profile *)

   set img to (open alias "Macintosh HD:Desktop Folder:cowgirl.jpg") 

   set theProf to profile 1 of img (* theProf refers to one embedded profile *)

  (* gather some profile object properties on this profile in a string 

   variable called mesg; display them in a dialog box with the display 

   dialog scripting addition *)

   set mesg to "Profile name: " & name of theProf & return

   set mesg to mesg & "preferred CMM: " & preferred CMM of theProf &¬

   return

   set mesg to mesg & "device class: " & device class of theProf & return

   set mesg to mesg & "color space: " & color space of theProf & return

   set mesg to mesg & "creation date: " & creation date of theProf &¬

   return

   set mesg to mesg & "platform: " & platform of theProf & return

   set mesg to mesg & "device namufacturer: " & device manufacturer of¬ 

   theProf & return

   set mesg to mesg & "device model: " & device model of theProf & return

   set mesg to mesg & "quality: " & quality of theProf & return

end tell

display dialog mesg







    Team LiB   Previous Section   Next Section