Sample ColorSyncª AppleScripts Now you can use AppleScript to do the same kinds of ColorSync matching previously available only in the ColorSync Photoshop Plug-ins or in third party applications. This scriptability was achieved by making the ColorSync Extension a faceless background application, in addition to the traditional extension it used to be. As an application, ColorSync now has an AppleScript dictionary. You can examine this dictionary by launching Script Editor, selecting ÒOpen DictionaryÓ from the File menu, and then selecting ÒColorSync ExtensionÓ in your extensions folder. Script Editor is typically located in the ÒApple ExtrasÓ folder inside the ÒAppleScriptªÓ folder. After selecting ÒColorSync ExtensionÓ, Script Editor brings up a window with all the commands the ColorSync Extension can respond to. You can do many things with a scriptable ColorSync, from simple one-line droplet scripts to complex multi-operation applets. To help you get started, we've included several sample scripts. You can copy text from these scripts or modify them for your own use. This document provides a description for each included script. Remember, these scripts are not the final word in ColorSync scriptingÑthey're just a starting place. Commands and Attributes Drag the ColorSync Extension onto Script Editor and you'll notice several commands and attributes. In addition to the familiar Embed, Match, Proof, and Match Link operations there is an UnEmbed operation, which can remove embedded profiles. Many scripting features relate to profile management. Until now it's been easy to match images and embed profiles, but not so easy to determine the state of images and profiles. There was no way to tell if an image contained a profile, or to determine what device that profile represented, without resorting to somewhat esoteric resource editing tools. ColorSync provides an extensive suite of profile, image, and device attributes, many of which can be modified. Examine the ColorSync Extension's dictionary in Script Editor and you'll see four classes toward the end of the list - application, profile, image and display. Two attributes of the Application class, quit delay and preferred CMM, are the same as in earlier versions of ColorSync. The profile locations (system profile location, default RGB profile location, etc.) represent file aliases on disk, and correspond to the attributes system profile and default RGB profile from ColorSync 2.5. Scripts compiled with 2.5 will still work fine, but when opened using 2.6 or later will read "system profile location" instead of "system profile". The attributes system profile, default RGB profile, etc. represent profile objects, meaning installed ColorSync profiles, as opposed to simple file aliases. The advantage of using a profile object is the ability to get information about the profile, such as its color space, description, or connection space. The Profile class contains several attributes of profiles which can be referred to and modified. The scripts Show Profile Info and Set Profile Info are good examples of using these. Keep in mind that a profile may be an installed ColorSync Profile or may be a profile embedded in an image. Installed profiles may be referred to by name, by index, or by evaluating a conditional such as "every profile whose color space is RGB". Remember that if you're working with a profile embedded in an image, the image must first be opened. Think of a profile in an image in the same way you would a paragraph in a text file - to get the paragraph, first open the text file, then refer to the paragraph. The Image class contains several image attributes including color space and profile, as in embedded profile. Images may be opened, saved, and closed. Saving an image is necessary if you've modified any attributes of a profile the image contains. The Display class contains attributes related to the user's display environment. If only one monitor is present, it will be referred to as "display 1", if more than one is present each will be referred to by index in the same way as the Monitors & Sound control panel indexes multiple monitors. Monitors may also be referred to by name, with older monitors returning a generic display name and newer monitors returning a more specific description. Notes and Warnings When experimenting with these scripts, you should at first only run them on copies of your original images, since many of the scripts will overwrite your original files. Once you understand what the scripts do, and have modified them to suit your own particular needs, then you can safely use the scripts on your original files. Because ColorSync Extension operates as a faceless background application, you won't see ColorSync in the application menu when you run one of these scripts. ColorSync allows the scripting of matching operations on TIFF, JPEG, and GIF images. Note however that not all file types support all color spaces, for example, you can't match a GIF file from RGB to CMYK because there's no such thing as a CMYK GIF. ÒWhere is ColorSync Extension?Ó When you run an unmodified version of any of these scripts, you may see a dialog appear with the prompt ÒWhere is ColorSync Extension?Ó. The scripts store the path to the ColorSync Extension as an alias, meaning when you try to run a script on a machine other than the one it was compiled on the alias will no longer be valid, and the script will not be able to locate the ColorSync Extension. To avoid the dialog, you should recompile each script on your own system. To recompile a script, simply drag it onto the Script Editor. The familiar ÒWhere is ColorSync Extension?Ó message will appear, so just select the ColorSync Extension in your extensions folder. Script Editor will now bring up a window with the actual code of the script. In order to get the script to recompile, youÕll need to make a change to it, for instance, adding a return at the top, then deleting it again. Just hit "Save" and the script will remember where to find the ColorSync Extension on your system from now on. Actually this is a good chance to get acquainted with how AppleScript works. Look at how the sample scripts are written and think about how you could modify them to suit your own needs. Embed, Match, and Proof to specific profiles The three basic scripts Embed specific profile, Match to specific profile, and Proof to specific profile are all variations on a single theme. They all show how to work with specific profiles installed in the ColorSync Profiles folder. Any of these scripts can be duplicated and easily modified to suit your own workflow simply by replacing a few profile names. We've included these examples of the three most common ColorSync operations so users can choose the script that most closely resembles the solution they need, then duplicate the example script and modify it to use their own specific profiles. When customized these types of scripts are very useful for workflow automation.. Embed, Match, and Proof to chosen profiles Similar to the above three examples, but the profiles used in these scripts are chosen by the user each time the script is launched. This type of script is useful for general use on a variety of images with a variety of profiles, since no specific profiles are hard coded into the scripts themselves. When these scripts are launched a dialog appears with a prompt asking the user to choose a profile or profiles to be used in the operation. Remove profile from image It's possible to remove a profile from an image with the "unembed" command. Usually if an image has an embedded profile it's best to leave it there, since the embedded profile describes the device upon which the image was created or last modified, but profiles may now be removed if deemed necessary by dragging an image onto the droplet Remove Profile from Image. Rename Profile You may be familiar with the names of many of the profiles in the ColorSync Profiles folder, but did you know the profiles have an internal name as well? The internal name, or profile description tag, is the text that appears in the ColorSync control panel when selecting one of the popup menus of profiles. Usually the profile description tag is set by the manufacturer to be the same as the file name on disk, but simply changing a profile's file name does not change it's description tag. You may also run across a profile whose file name doesn't remotely resemble its profile description, especially if the profile was created on or designed for a PC workflow. The droplet Rename Profile simplifies profile management by allowing the user to change a profile's description tag. Dragging a profile onto Rename Profile will set the profile's description tag to the profile's file name, so both values will be the same. If the file name is subsequently changed however, the description tag will retain its last value until dragged onto Rename Profile again. Set Profile Info Users can now modify several attributes of an ICC profile, including preferred CMM, platform, manufacturer, creator, rendering quality, rendering intent, and internal name using Applescript. The droplet Set Profile Info is included for instructional purposes only. Drag the script onto Script Editor and you'll notice that the significant commands for modifying the profile attributes have been commented out, meaning the lines of code are visible, but temporarily disabled. Pick an attribute you want to experiment with and remove the comments from the correspoding line of code, then save the script with a different name. Pick an image or a profile to work with and duplicate it, then drag the duplicate onto your modified script. It's important to work with a disposable copy of an image or profile when modifying attributes in case you forget the original attribute values. Drag a profile onto the script to modify attributes of the profile, or drag an image onto the script to modify attributes of a profile embedded in the image. Show Profile Info ColorSync allows users to determine not only the internal name of an embedded profile but also the device class, platform, manufacturer, device model, color space, connection space, rendering quality, rendering intent, preferred CMM, creator, version, creation date, location and size of a profile either on disk or embedded into an image. Drag a profile or an image with an embedded profile onto the droplet Show Profile Info to display a dialog containing most of these attributes. Note the profile location attribute has been left out of this script to minimize dialog size. Build Profile Info Web Page Drag a folder onto this droplet and the script will search all images in the folder for any embedded profiles. The script will then generate an HTML page called ProfileInfo.html displaying the images and their corresponding profile attributes in table format. Just drag the generated HTML file onto your browser to see which of your images have embedded profiles and what data those profiles contain. Examing this script in Script Editor not only shows you how to get and display profile information but also shows how you can use AppleScript to build a web page on the fly. Recursive Embedder This script will embed the display profile of your main display into any images which currently do not contain any embedded profile. The display profile is a good profile to embed because it should accurately reflect your viewing environment. The interesting thing about Recursive Embedder is that it can handle dragging a single file, multiple files, a single folder, multiple folder, files and folders, or even entire volumes. Error checking has been added to enable the user to process large image archives or entire web sites with this script without memory errors stopping the entire process. Folders with a high number of items can easily cause a script to run out of memory, but Recursive Embedder handles this problem by skipping over error folders and generating a report of which folders encountered problems. The embedding operation has been placed into a separate routine so users can easily modify the script, maintaining the core error handling routines while replacing the operation routine with one of their own choosing. Change Display Profile All the monitor profiles that ship with ColorSync, and all the profiles you create with the Default Calibrator, contain video gamma information stored in the Video Card Gamma Tag. This VCGT information is what allows ColorSync to change the appearance of your display, allowing you to emulate different video gammas (2.2, 1.8, 1.0) and different white points (9300, d65, d50, or uncorrected). Meaning, you can change the overall color balance and contrast of your monitor by changing the profile associated with your display. One way to change the profile associated with your display is by opening up Monitors & Sound and selecting various profiles from the ColorSync Profiles panel under the Color button. Another way is by using Applescript to do the same thing. Drag a profile with a gamma tag onto Change Display Profile to associate that profile with your main display. For instance, let's say you've created several profiles with the Default Calibrator, each simulating a different white point and gamma. Instead of opening the Monitors & Sound control panel and selecting each profile from the list, you can just drag a profile onto this script to change the apparent white point and gamma of your display. Mimic PC Monitor Similar to the previous script, Mimic PC Monitor changes the profile associated with your display, but when it quits, the script will restore your display's original associated profile. Initially the script uses the sRGB Profile, but it can be easily modified. The best thing to do is to run the Default Calibrator to generate a profile of your display emulating a 1.8 gamma and either uncorrected white point or 9300 white point. These are the basic Mac settings. Then run the Default Calibrator again but instead of 1.8 gamma choose 2.2 gamma, that's the standard gamma of most PC monitors. Then modify this script so it specifies your 2.2 gamma calibrated profile instead of the sRGB Profile. You can leave your monitor set to your normal 1.8 gamma calibrated profile most of the time, but if you want to temporarily set your display to 2.2 gamma, just launch this script. When it quits, it'll restore your original gamma. Running this script is useful if you want to get a quick and dirty approximation of what a given image or web page will look like when viewed in different gammas and white points. It is not as accurate as doing a match or proof of a given image from one device profile to another. Doing a match or a proof takes phosphor values of each monitor into account, whereas this method just shows how different gammas and white points affect the image's appearance. This script is not the be-all, end-all of color management. You still should embed profiles into images you give away, and you still should match images you receive from their original space into your viewing space. DropEmbed DropEmbed is a very simple script that embeds the current display profile into any image dropped onto it. Most users will find embedding useful, since embedding ÒstampsÓ the image with the display environment used during the imageÕs creation. When you send the image to someone else, the recipient can use the embedded profile to match the image to their own display device, and get a more accurate idea of what the original image looked like. To examine the code for DropEmbed, just drag the script onto the application Script Editor. PC to Mac Gamma This script provides an example of matching an image by mapping the colors in an image from one device to another. In this case weÕre going from a standard PC monitor profile to the iMac Display profile. Often images created on a PC look washed out when displayed on a Mac because of the difference in gamma between the two devices. PC monitors are typically set to a 2.2 gamma, while Mac monitors are typically set to a 1.8 gamma. Dragging an image onto this script will correct for that, essentially increasing contrast in the image. Match to CMYK Another matching script, but this time weÕre matching for printer output. Dragging an image onto this script matches the image to your default CMYK profile, converting the image from its original color space to CMYK. If you examine the code in this script, you'll notice a difference between this script and the previous one. In PC to Mac Gamma we specified both a source profile and a destination profile for the match, because we knew specifically which profile we wanted to use for each. In Match to CMYK however, we know we want the destination profile to be the default CMYK profile, but we donÕt know what the source profile is. Leaving the source profile unspecified like this allows the matching script to work on images with various source color spaces. In this case the ColorSync Extension will either use the profile that is embedded in the source image as the source profile or, if there is no embedded profile, it will use the default space profile that is the same space as the source image. By leaving the source profile unspecified, we've made the script more flexible. The default CMYK profile can be set either by using the ÒColorSyncÓ control panel or by using AppleScript to set the Òdefault CMYK profileÓ property. DropProof This script matches an image from its original color space to the default CMYK profile and then back to your display's profile. This is useful for previewing on screen what an image will look like when printed on a specific printer, a process commonly known as "soft proofing". The profile "default CMYK profile" is one of several default space profiles ColorSync keeps track of, any of which can be set using the ColorSync control panel. So by changing the setting of the Default CMYK Profile popup in the ColorSync control panel, you can change which printer this script will use as a destination when doing the soft proof. It's similar to the script Match to CMYK, but goes the extra step of matching back to your monitor. Here's a typical process you might go through: 1) Scan or create a new image, then modify it to suit your purposes and save it. 2) Go to the ÒColorSyncÓ control panel and set your System Profile to your monitorÕs profile. You may also want to create a profile for your monitor using the ÒCalibrateÓ button in the Monitors & Sound control panel, or if you're using a ColorSync Display (aka AppleVision Display) you can export a saved calibration setting as a ColorSync profile. 3) Go to the ÒColorSyncÓ control panel and set the Default CMYK profile to the profile for your printer, if you have a printer and a profile to go with it, or simply set the popup to ÒGeneric CMYK ProfileÓ. 4) Make a copy of your saved image and drag it onto DropProof. The applet will launch and tell ColorSync to perform matching on the image. 5) Open up the modified image in a graphics program to see what the printed colors will look like as closely as they can be reproduced on your monitor. Note that the above process assumes your printer to be a CMYK printer, such as a Apple Color LaserWriter. If your printer is an RGB device, such as a StyleWriter, you wouldn't want to use this particular script without first modifying the script to proof the image from your display to your RGB printer profile and then back to your display. When you look at the proofed image, you can determine whether or not the printed colors are going to be close enough to what you were expecting. If they are, go ahead and print the original image. If the colors are too far off from what you had in mind, you can modify the original image, then proof a copy of that to see how the new changes look. AutoMatch AutoMatch is a bit more complicated than the previous scripts, but it's a good example of the real power of the scriptable ColorSync Extension. Just double click AutoMatch and it creates two folders on your desktop, one called Òrgb source imagesÓ and one called ÒdestinationsÓ. To best see what's happening you'll want to open up the ÒdestinationsÓ folder, set it to List View, and twist open all the subfolders, like this: Ê Applescripts calling ColorSync can handle images in TIFF, JPEG or GIF format, and support for other image file types may be added in the future. If you do inadvertently drag an unsupported image into the source folder, AutoMatch will create a new subfolder called "wrong file types" and place any unsupported file type images inside. Just drag an RGB image into the Òrgb source imagesÓ folder. While the script is still running, it checks that folder every fifteen seconds. When it finds an image, it makes a copy of the original and then performs a series of ColorSync operations. You can watch the various images get created as this happensÑthat's why it's a good idea to set up the folder view as shown above. The first thing the script does is to embed the display profile in the image, which is a pretty useful standard operation. Then it creates a copy of the image matched to the ColorMatch press profile. The matched image is ready to be printed, since ColorSync has adjusted the colors of the image to best fit the gamut of the printer it's destined for. The script also automatically makes a proof of the image going to the screen. The proofed image is what you'd open up in a graphics program to see what the image will look like when it's printed. So theoretically, looking at the proof you'll see what the press will print out. Once this script is launched, all you have to do is drag an image, or several images, into the ÒsourceÓ folder and let ColorSync and AppleScript do the rest. Again, this is just an example of a large, multi-operation script you could write to automate frequently performed operations in your own work flow. Feel free to modify AutoMatch or any of the other scripts to work with your own profiles for your own devices, or in any other way you find useful. ©2000 Apple Computer. Inc. Apple, the Apple logo, and Macintosh are trademarks of Apple Computer, Inc., registered in the U.S.A. and other countries. Power Macintosh and ColorSync are trademarks of Apple Computer, Inc. All other product names are trademarks or registered trademarks of their respective holders. Mention of non-Apple products is for information purposes and constitutes neither an endorsement nor a recommendation. Apple assumes no responsibility with regard to the selection, performance, or use of these products. Updated August 8, 2000.