Skip to main content
Inspiring
October 11, 2013
Question

Colour sampler in CS2

  • October 11, 2013
  • 3 replies
  • 1963 views

Can anyone tell me if .colorSamplers is supported in good ol' CS2?

When i runn the following code I get: Undefined is not an object

var sampler = app.activeDocument.colorSamplers.add([0,0]);

Thank you

This topic has been closed for replies.

3 replies

Inspiring
October 11, 2013

With a document open in CS2 run this line in ESKT with Photoshop as the target app.

app.activeDocument.reflect.properties

If colorSamples are part of the CS2 Object Model it should be listed in the doc properties.

For most methods that use UnitValue object you can supply a number as the value and Photoshop uses the rulerUnit as the unit so I don't think the arguments are the problem. Even if they were I would expect a different error message.

Note that even with CC if you run that line in ESTK with the target app set to ESTK you will get the same error message. ESTK doesn't have an app.activeDocument. Did you run your code in ESTK with the wrong target app?

GhoulfoolAuthor
Inspiring
October 14, 2013

Running that I get:

backgroundLayer

bitsPerChannel

colorProfileType

colorProfileName

mode

componentChannels

activeHistoryState

activeHistoryBrushSource

activeLayer

activeChannels

info

fullName

height

managed

saved

name

path

quickMaskMode

resolution

selection

width

histogram

pixelAspectRatio

xmpMetadata

layers

layerSets

artLayers

channels

historyStates

layerComps

pathItems

typename

parent

__proto__

So I'm guessing no, then

pixxxelschubser
Community Expert
Community Expert
October 11, 2013

I'm also not sure about CS2.

But this code (to add a ColorSampler) works definitly in CS2:

var posX = 10;

var posY = 20;

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putClass( charIDToTypeID( "ClSm" ) );

desc.putReference( charIDToTypeID( "null" ), ref );

var desc1 = new ActionDescriptor();

desc1.putUnitDouble( charIDToTypeID( "Hrzn" ), charIDToTypeID( "#Pxl" ), posX );

desc1.putUnitDouble( charIDToTypeID( "Vrtc" ), charIDToTypeID( "#Pxl" ), posY );

desc.putObject( charIDToTypeID( "Pstn" ), charIDToTypeID( "Pnt " ), desc1 );

executeAction( charIDToTypeID( "Mk  " ), desc, DialogModes.NO );

Have fun

Chuck Uebele
Community Expert
Community Expert
October 11, 2013

Yes, that snippet of Action Descriptor code has the unit value included also.

Chuck Uebele
Community Expert
Community Expert
October 11, 2013

I'm not sure about CS2, as I no longer have it, but you might need to define the point array with a pixel value such as:

var pt = ['0 px','0 px']

I think the need for the pixel value was dropped in later versions.