home *** CD-ROM | disk | FTP | other *** search
Wrap
from JascApp import * import JascUtils def ScriptProperties(): return { 'Author': 'Linda Nieuwenstein', 'Copyright': 'Copyright (C) 2002-2003, Jasc Software Inc., All Rights Reserved. Permission to create derivate works of this script is granted provided this copyright notice is included', 'Description': 'The the current image and split to CMYK, putting the separate channels back as layers in a layer group.', 'Host': 'Paint Shop Pro', 'Host Version': '8.00' } def Do(Environment): if JascUtils.RequireADoc( Environment ) == App.Constants.Boolean.false: return # keep track of the doc we are starting with TargetDoc = App.TargetDocument # start by splitting the current image. App.Do( Environment, 'SplitToCMYK', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) # the split created 4 new documents and puts them at the end of the open list. # make a four element list that we can reorder. At this point we don't # care about the contents, just that it has four elements NewDocs = App.Documents[-4:] # grab the last four docs # now loop over the four newest docs. for ChannelDoc in App.Documents[-4:]: Name = ChannelDoc.Title if Name.find( 'Black' ) != -1: NewDocs[0] = ChannelDoc # make Black first elif Name.find( 'Yellow' ) != -1: NewDocs[1] = ChannelDoc # make Yellow next elif Name.find( 'Magenta' ) != -1: NewDocs[2] = ChannelDoc # then Magenta elif Name.find( 'Cyan' ) != -1: NewDocs[3] = ChannelDoc # make Cyan last FirstChannel = App.Constants.Boolean.true # need special handling on the first one # We use explicit specification of which document to work on by adding a fourth # parameter to the App.Do call. For operations on one of the single channel # images we use one of the saved docs. For operations on the original doc we use # the saved TargetDoc. for Doc in NewDocs: # this shouldn't be necessary, but at the moment paste as new layer has a bug, # so we promote manually. This assumes the original image is RGB. App.Do( Environment, 'IncreaseColorsTo16Million', {}, Doc ) # copy it to the clipboard App.Do( Environment, 'Copy', {}, Doc ) # paste it into the existing document - note the specification of target doc App.Do( Environment, 'PasteAsNewLayer', {}, TargetDoc ) # when we pasted it the layer came in as Raster Layer n, and we want to know what # channel it represents, so pick up the image title and use that to determine # the layer name. Out of split to CMYK the image will be named CyanN, YellowN, MagentaN, and BlackN. NewLayerName = Doc.Title if NewLayerName.find( 'Black' ) != -1: NewLayerName = 'Black Channel' elif NewLayerName.find( 'Yellow' ) != -1: NewLayerName = 'Yellow Channel' elif NewLayerName.find( 'Magenta' ) != -1: NewLayerName = 'Magenta Channel' else: NewLayerName = 'Cyan Channel' # now that we have the layer name, rename it App.Do( Environment, 'LayerProperties', { 'General': { 'Name': NewLayerName, }, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }, TargetDoc ) # we want the channels to end up inside of a layer group, so after we # paste the first channel in create a layer group to hold it, and then select # the layer inside the group so subsequent creates go where we want them. if FirstChannel == App.Constants.Boolean.true: FirstChannel = App.Constants.Boolean.false # create the layer group App.Do( Environment, 'NewLayerGroup', { 'General': { 'Name': 'CMYK Channels', }, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Match } }, TargetDoc ) # select the member of the group rather than the group itself NewLayer = App.Do( Environment, 'SelectLayer', { 'Path': (0,0,[1],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }, TargetDoc) # do the close in silent mode since we don't want to save changes App.Do( Environment, 'FileClose', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Match } }, Doc )