Create plain color files
Posted: Fri Feb 16, 2018 4:26 am
Hi,
Hoping someone can help with this, I found this post which was almost 10 years old! It seems that it will do what I need, but it errors on line 27
With "Error 1220 Illegal Argument color.rbg["hexValue"]=part[1];
Thank you
Hoping someone can help with this, I found this post which was almost 10 years old! It seems that it will do what I need, but it errors on line 27
With "Error 1220 Illegal Argument color.rbg["hexValue"]=part[1];
Thank you
Patrick wrote:Try this:
CSV:Code: Select allorange,fe7011
apple,c80303
banana,ffd800
pear,00ff00
JSX:Code: Select allfunction SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions()
jpgSaveOptions.embedColorProfile = true
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE
jpgSaveOptions.matte = MatteType.NONE
jpgSaveOptions.quality = jpegQuality //1-12
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE)
}
// read in result file
var crop = new File("/c/sandbox/fruit.csv");
// open file
crop.open('r');
while (!crop.eof)
{
// read line of csv
var line = crop.readln();
var part = line.split(',');
// create doc
var doc = app.documents.add(100, 100, 72, part[0], NewDocumentMode.RGB);
// define your fill color
var color = new SolidColor();
color.rgb["hexValue"] = part[1];
// fill layer
doc.selection.selectAll();
doc.selection.fill(color);
// save file
var image = new File("/c/sandbox/"+ part[0] +".jpg");
SaveJPEG(image,12);
// close document
doc.close(SaveOptions.DONOTSAVECHANGES);
}
// close file
crop.close();
Patrick