-
Scripting text causes mac and pc to run out of memory
Hello all,
I’ve written a script that reads text in an array and assigns that text to the selected textItem (Selected Text Layer in Photoshop). This works great for saving many files in a short amount of time, but there seems to be a memory problem if my selected text layer has different character styles. For example: if my text layer has Faux Bold or Small Caps turned on (In the Character window) when running the script. Photoshop will quickly eat up all of my computers memory making it non-responssive. This occurs on both PC and MAC. Is there any workaround to this? I’d like to be able to use these character styles on my fonts when running this simple script. Any help would be much appreciated.
Below is the script I’m running.
Thanks,
Rob///////////////////////////////////////////////////
var defaultRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;//POINTING TO THE PATH WHERE THE FILES SHOULD BE SAVED
var cPath = Folder.selectDialog(“Select a folder for the output files”);//ARRAY OF TEXT TO POPULATE TEXTITEM
var textArray = [
“Sample Text test 1”,
“here is some more text you would like”,
“\”This is an example of a quote\””,
“Hope everything is going well”,
“I’d like some dinner now”,
“Time is of the essance”,
“Do we need to go on?”,
“\”Me\” This is me in quotes”,
“Colorado is a great state”,
“Do you like to rock climb?”
]//ARRAY OF FILE NAMES
var fNameArray = [
“01”,
“02”,
“03”,
“04”,
“05”,
“06”,
“07”,
“08”,
“09”,
“10”
]var AD = app.activeDocument
//LOOP THAT DOES ALL OF THE WORK
for(a=1;a<=textArray.length;a++) { var TextLayer = AD.activeLayer; var txtRef = TextLayer.textItem; txtRef.contents = textArray[a-1]; var newName = ""; var newName = fNameArray[a-1]; saveForWebPNG(cPath,AD,100,newName); } alert("I'm Done :)"); //SAVE PNG FUNCTION function saveForWebPNG(toWhere,file,qual,name) { toWhere = new File(toWhere+"/"+name+".png"); var opts = new ExportOptionsSaveForWeb(); opts.interlaced = false; opts.PNG8 = false; opts.transparency = true; opts.format = SaveDocumentType.PNG; opts.includeProfile = false; file.exportDocument(toWhere, ExportType.SAVEFORWEB, opts); } app.preferences.rulerUnits = defaultRulerUnits;