Skip to content

Instantly share code, notes, and snippets.

@tinyx3k
Forked from juliend2/gist:757422
Created September 18, 2021 10:09
Show Gist options
  • Save tinyx3k/7301d0a82f6cc03c34d3013aa1299615 to your computer and use it in GitHub Desktop.
Save tinyx3k/7301d0a82f6cc03c34d3013aa1299615 to your computer and use it in GitHub Desktop.
Photoshop Javascript to increment text layer value and save for Web (in a loop)
function sfwPNG24(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = false;
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
}
/*
Incrementing a number inside a text layer then Saving it in PNG
*/
var layer = activeDocument.layers[0];
if (layer.kind == 'LayerKind.TEXT') {
for (var i=1; i < 51; i++) {
layer.textItem.contents = i.toString();
sfwPNG24( '/Applications/MAMP/htdocs/remax/images/img_ui/mapMarkers/mapMarker_'+ i +'.png');
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment