Page 1 of 1

create solid fillled files from csv

Posted: Thu Apr 03, 2008 2:35 am
by flieckster
Hi guys, i want to make a csv file that looks like this.

file name hex value
1234 fdfcfc

and i want photoshop to read the csv file and export out all the files with solid fills of the hex values in the list.
is this possible?

thanks guys

create solid fillled files from csv

Posted: Thu Apr 03, 2008 2:36 pm
by Patrick
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

create solid fillled files from csv

Posted: Wed Apr 09, 2008 9:13 pm
by flieckster
thanks for the info patrick, but i think i'm having a problem loading scripts in photoshop vs bridge. can you direct me to place where it describes where you load photoshop scripts and how to use them?

thanks i cant wait to use this.

create solid fillled files from csv

Posted: Wed Apr 09, 2008 9:22 pm
by Patrick
You can save the code as a .jsx file wherever you want on your hard drive, and in photoshop go to:

File -> Scripts -> Browse...

If I use a script a lot, just record a action of loading the script like above. You can then use the action as a one button way of getting to the script after that.

Patrick

create solid fillled files from csv

Posted: Thu Apr 10, 2008 4:08 pm
by flieckster
// create doc
var doc = app.documents.add(100, 100, 72, part[0], NewDocumentMode.RGB);

says undefined is not an object.

create solid fillled files from csv

Posted: Thu Apr 10, 2008 4:14 pm
by flieckster
forget it, i figured it out. wow this rocks.

Re: create solid fillled files from csv

Posted: Sat Dec 10, 2016 9:34 am
by raunaqsingh
Hi, how did you solve the issue?

Re: create solid fillled files from csv

Posted: Sat Dec 10, 2016 9:34 am
by raunaqsingh
flieckster wrote:forget it, i figured it out. wow this rocks.
Hi, how did you solve the issue?