Skip to main content
Participant
October 25, 2012
Question

auto copy one pixel row from image....

  • October 25, 2012
  • 1 reply
  • 1466 views

Can someone help me write a script that:

- from my selection (1 pixel row)

- auto copy selected area to next row into new layer (up or down)... and so on (into the same second layer)... until it reaches the end of the image

- the result is a photos with two layers; in the first is my image and in second is multicolored pattern

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
October 25, 2012

You could try this, but from a certain height on simply transforming might be considerably quicker:

// 2012, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var originalRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

myDocument = app.activeDocument;

// new layer;

var id14 = charIDToTypeID( "CpTL" );

executeAction( id14, undefined, DialogModes.NO );

var theLayer = myDocument.activeLayer;

var theHeight = theLayer.bounds[3]-theLayer.bounds[1];

var theCheck = false;

var theCounter = 1;

// duplicate, move and merge the layer;

while (theCheck == false) {

if (theLayer.bounds[3] < myDocument.height) {

var theCopy = theLayer.duplicate();

theCopy.translate(0, theLayer.bounds[3] - theLayer.bounds[1]);

theCounter++;

var theLayer = theCopy.merge();

//$.writeln(theCounter);

}

else {theCheck = true};

};

// reset;

app.preferences.rulerUnits = originalRulerUnits;

};

dejansucAuthor
Participant
October 26, 2012

Exactly what I was looking for...

What should I change in this script:

1. to copy selected line horizontaly UP

2. to copy selected line verticaly LEFT

3. to copy selected line verticaly RIGHT

Thnx!!

c.pfaffenbichler
Community Expert
Community Expert
October 26, 2012

To duplicate the selected part up changing the if-clause and the line that tranlate (moves) 

if (theLayer.bounds[1] > 0) {

var theCopy = theLayer.duplicate();

theCopy.translate(0, theLayer.bounds[1] - theLayer.bounds[3]);

should do it.

For left

if (theLayer.bounds[0] > 0) {

var theCopy = theLayer.duplicate();

theCopy.translate(theLayer.bounds[0] - theLayer.bounds[2], 0);