This content has been marked as final.
Show 5 replies
-
1. Re: convert rgb to color image?
Paul Riggott Sep 13, 2011 12:39 PM (in response to bsnyder175)This should be close....
#target photoshop var inputFile = File.openDialog("Please select CSV file.","CSV File:*.csv"); var outputFolder = Folder.selectDialog( "Please select output folder"); inputFile.open('r'); inputFile.readln(); var datFile=[]; while(!inputFile.eof){ var line = inputFile.readln(); if(line.length > 5) datFile.push(line); } inputFile.close(); var FillColour = new SolidColor; for(var a in datFile){ var line = datFile[a].split(','); var ColourName = line[0].toString().replace(/^ +| +$/g,''); FillColour.rgb.red = line[1].toString().replace(/^ +| +$/g,''); FillColour.rgb.green = line[2].toString().replace(/^ +| +$/g,''); FillColour.rgb.blue = line[3].toString().replace(/^ +| +$/g,''); app.backgroundColor = FillColour; app.documents.add(new UnitValue( 500, 'px' ), new UnitValue( 500, 'px' ), 72, ColourName, NewDocumentMode.RGB, DocumentFill.BACKGROUNDCOLOR); var saveFile = File(outputFolder +"/"+ColourName+".jpg"); SaveForWeb(saveFile,50); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); } function SaveForWeb(saveFile,jpegQuality) { var sfwOptions = new ExportOptionsSaveForWeb(); sfwOptions.format = SaveDocumentType.JPEG; sfwOptions.includeProfile = false; sfwOptions.interlaced = 0; sfwOptions.optimized = true; sfwOptions.quality = jpegQuality; activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions); } -
2. Re: convert rgb to color image?
bsnyder175 Sep 13, 2011 12:58 PM (in response to Paul Riggott)Paul to the rescue once again! From initial tests, the script is working great. I'll have run it on the entire list and see how it goes.
Thanks so much, Paul.
-
3. Re: convert rgb to color image?
bsnyder175 Sep 13, 2011 1:30 PM (in response to Paul Riggott)Hey Paul,
Right now, the filename handles spaces (i.e. "Pink Cadillac") by inserting dashes instead (Pink-Cadillac). Is it possible to have the file name retain the spaces found in the csv, or is that just how spaces are handled?
-
-
5. Re: convert rgb to color image?
bsnyder175 Sep 13, 2011 2:15 PM (in response to Paul Riggott)Aha. You're right; that did the trick.
Thanks!




