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
create solid fillled files from csv
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
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
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.
thanks i cant wait to use this.
create solid fillled files from csv
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
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
// create doc
var doc = app.documents.add(100, 100, 72, part[0], NewDocumentMode.RGB);
says undefined is not an object.
var doc = app.documents.add(100, 100, 72, part[0], NewDocumentMode.RGB);
says undefined is not an object.
-
- Posts: 2
- Joined: Sat Dec 10, 2016 9:32 am
Re: create solid fillled files from csv
Hi, how did you solve the issue?
Last edited by raunaqsingh on Sat Dec 10, 2016 9:34 am, edited 1 time in total.
-
- Posts: 2
- Joined: Sat Dec 10, 2016 9:32 am
Re: create solid fillled files from csv
Hi, how did you solve the issue?flieckster wrote:forget it, i figured it out. wow this rocks.