Good Day and thanks for the help,
Basically, I need to take a layer & nudge it up one pixel
save this as 001.png
then rinse & repeat,
nudging by one pixel and incrementing the filename until it reaches 100.
Much thanks if you can help,
jarr_d
simple script - maybe can be batched
simple script - maybe can be batched
Code: Select all// reference the open document
var docRef = app.activeDocument;
var layRef = docRef.activeLayer;
// start the counter at 1
var i = 1;
while (i <= 100) {
// nudge up one pixel
layRef.translate(0,-1);
// add padding zeros to the file names
if (i < 10) {
var fname = "00" + i;
};
if (( i < 100) && (i > 9) ) {
var fname = "0" + i;
};
if (i > 99) {
var fname = i;
};
// save png file
pngSaveFile = new File("/c/" + fname + ".png");
docRef.saveAs (pngSaveFile , PNGSaveOptions, true, Extension.LOWERCASE);
// increment counter
i++;
};
One thing to note is this will only work properly if the image you are working with is 72dpi. The translate() function assumes this, if you work with a different resolution let me know and I can alter the code. Hope this helps,
Patrick
var docRef = app.activeDocument;
var layRef = docRef.activeLayer;
// start the counter at 1
var i = 1;
while (i <= 100) {
// nudge up one pixel
layRef.translate(0,-1);
// add padding zeros to the file names
if (i < 10) {
var fname = "00" + i;
};
if (( i < 100) && (i > 9) ) {
var fname = "0" + i;
};
if (i > 99) {
var fname = i;
};
// save png file
pngSaveFile = new File("/c/" + fname + ".png");
docRef.saveAs (pngSaveFile , PNGSaveOptions, true, Extension.LOWERCASE);
// increment counter
i++;
};
One thing to note is this will only work properly if the image you are working with is 72dpi. The translate() function assumes this, if you work with a different resolution let me know and I can alter the code. Hope this helps,
Patrick
simple script - maybe can be batched
You can replace the block of if statements to pad the number with the function below
Code: Select allfunction zeroPad(num,pad) {
var z = Math.pow(10,Number(pad))
return num < z ? (Number( num) + z).toString().substr(1): num
}
To call the function in the loop use
Code: Select allzeroPad( i, 3 );
Code: Select allfunction zeroPad(num,pad) {
var z = Math.pow(10,Number(pad))
return num < z ? (Number( num) + z).toString().substr(1): num
}
To call the function in the loop use
Code: Select allzeroPad( i, 3 );
simple script - maybe can be batched
Or:
Code: Select allfunction zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
};
Code: Select allfunction zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
};
simple script - maybe can be batched
wow guys - thanks so much
This is for a samurize config i'm working on - it was such a pain doing it manually (kept forgetting which number I was at & if i had already nudged it & whatnot...
again - HUGE, HUGE, HUGE thanks!!!!
now to figure out how to work it
saved it as
C:\Program Files\Adobe\Adobe Photoshop CS2\Presets\Scripts\onepixel.jsx
ran, and it worked !
Again, much much much thanks
I posted on the samurize forums about it here:
http://www.samurize.com/modules/ipboard ... entry87977 ... entry87977
This is for a samurize config i'm working on - it was such a pain doing it manually (kept forgetting which number I was at & if i had already nudged it & whatnot...
again - HUGE, HUGE, HUGE thanks!!!!
now to figure out how to work it
saved it as
C:\Program Files\Adobe\Adobe Photoshop CS2\Presets\Scripts\onepixel.jsx
ran, and it worked !
Again, much much much thanks
I posted on the samurize forums about it here:
http://www.samurize.com/modules/ipboard ... entry87977 ... entry87977