Two of those script failed to work in CS2, both of them make use of a layer translate to move a pasted-in watermark layer into position.
The PS7 script made use of pixels as units, because frankly, no other unit makes sense to me. It soon became obvious that CS2 was not using pixels for the translate, though, as all of the translates had the layer moving much farther than it should have.
I save/set/reset the units preferences, so I couldn't figure what the problem was. An alert(docRef.height-75) would always give me the appropriate answer (eg. "375 px"), but using that same value in the translate method for the layer never gave me the right response.
In any event, it appears that CS2 will only use "points" in translates now for some reason. I don't know exactly what a point is, but I have calculated it to be 4.86127 pixels in my photographs.
Once I applied this number to the math in the script, and did everything in points, I had no problem.
So, two things:
1) Is there a way to get translate() to use pixels for units?
2) What the heck is a point, and what problems am I potentially going to run into using this 4.86127 number in my calculations. Is the definition of points tied to DPI or something that can potentially change?
Thanks.
- Code: Select all
if ( documents.length > 0 )
{
/*
This function adds the MobileBurn watermark to the bottom of the current document.
It loads the watermark PSD, copies it, closes it, pastes it into the target document, moves it 2px left, and 75px from the bottom
*/
var docRef = app.activeDocument;
var docName = docRef.name;
if ( docRef.bitsPerChannel == BitsPerChannelType.EIGHT &&
( docRef.mode == DocumentMode.CMYK ||
docRef.mode == DocumentMode.RGB ||
docRef.mode == DocumentMode.LAB ) )
{
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
app.preferences.rulerUnits = Units.POINTS // must be in points to get around CS2 unit bug
app.preferences.typeUnits = TypeUnits.PIXELS
var watermarkFile = new File("c:\\htdocs\\mobile\\PSD Files\\watermark-red_text_fade-big.psd");
var watermarkRef = app.open(watermarkFile);
watermarkRef.artLayers[0].copy();
watermarkRef.close();
activeDocument=docRef;
var watermarkLayer=docRef.paste();
watermarkLayer.moveToBeginning(docRef);
// watermarkLayer.translate(-2,docRef.height-75); // This is what worked in PS7 using pixels
watermarkLayer.translate(-.41,docRef.height-15.428); // 15.428 equates to 75 pixels, the height of the watermark
app.preferences.rulerUnits = startRulerUnits
app.preferences.typeUnits = startTypeUnits
}
else
{
alert( "This function only operates on 8 bit RGB, CMYK or Lab documents." );
}
}
else
{
alert( "You must have a document open!" );
}
