Copy link to clipboard
Copied
How would you go about taking a somewhat transparent overlay and replacing the colors of the underlying layers and exporting to many files? I saw how Photoshop has a "Pixel Replacement" feature but you need to supply it with jpgs to swap instead of color codes. I'd prefer just color codes so I wouldn't have to make a ton of images.
If you could point me in the right direction I would appreciate it.
Edited:
For example:
I have a txt-file with this text:
color1;20;30;40;
color2;60;70;80;
color3;60;50;40;
and a file »testEmboss-psd« open and active in Photoshop with a top-level (meaning it is not in a Group) Solid Color Layer with the name »colorLayer«; the Script at the bottom will get me these:
...// 2012, use it at your own risk;
// thanks to xbytor;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var documentName = myDocument.name;
var basename = documentName.ma
Copy link to clipboard
Copied
Could you please post screenshots/mock-ups to illustrate what you are trying to achieve.
Copy link to clipboard
Copied
I have about 50,000 to make in different paint sample colors. Some are metallic or pearl paint swatches, while others are solid. I may need some bevel and emboss, or some type of highlight too, but this is the best I had on my home computer.
Copy link to clipboard
Copied
I think you are not giving enough detail for us to provide sensible advice.
What is the source, what is the result supposed to be (including Layer structure, transparencies, file formats), what is the data on which the changes are supposed to be based, …?
Copy link to clipboard
Copied
I have a database collected of over 50,000 different paint colors taken from a multi angle spectrophotometer with 25,45, and 75 degrees. The colors are natively Lab, but I also have them converted to RGB also. I can re-export them in almost anyway that photoshop would need them, prefferably not a solid colored jpg with a filename so that photoshop could use it. From that I'd like to blend two angles maybe a 25 and a 45 to get a more accurate color to display. Metallic colors may get an add noise filter to simulate the metallic. I haven't found a perfect formula in photoshop just yet that gets acceptable results everytime. I am still working out the small details.
Copy link to clipboard
Copied
Either it is just me having a hard time understanding what you are trying to achieve and what the source and intended final material is or you don’t communicate your intentions well, but I’ll give it another try:
If you have a database of Lab values you could use that to populate a layered file with Solid Color Layers for example (or edit existing Solid Color Layers).
Copy link to clipboard
Copied
Source: is an automotive paint scan taken from 3 angles.
The spectophotometer scans 3 angles face, flash, and side tones. I get cie or hunter Lab color from the device, but I convert the color to RGB on my end. So I can use either LAB or RGB colors taken from 3 angles to try to recreate a paint chip swatch.
The light source that the specrophotometer uses is D65, or daylight.
The final material is a paint chip swatch to be veiwed over a web browser/computer monitor.
I think I can get there by applying a 25 degree angle on one layer, and a 45 degree angle on another angle and use soft light as my blending options.
Copy link to clipboard
Copied
In what form is the data available? A CSV-file …?
And what RGB-space did you convert to?
If you want to use the angled measurements for the bevels I suppose you could create a sample file consisting of three Solid Color Layers with appropriate Layer Masks and then use the data to change those and save copies off of that file.
Copy link to clipboard
Copied
The database starts as microsoft SQL, however I can export it to a csv or other file type for the purpose of integrating to adobe for the job. I used easyRGB for the conversion math, they didn't specify what type of RGB. I am open to using a different set of match for the conversion, but there isn't a lot of resouces online.
Copy link to clipboard
Copied
Don’t think I ever heard if »easyRGB«, you might be better off sticking with Lab.
Copy link to clipboard
Copied
Adobe makes you round to the nearest integer, A and B values really need the decimal. Easyrgb.com has color conversions to go from LAB to XYZ to RGB, and several other color spaces. It isn't perfect, but it's the best I have unless you can name some better sources.
The biggest challenge is to automate the whole process. Adobe photoshop appears to only swap text efficiently, and also replace pixels if I supplied the jpgs. I don't see a way to replace colors with the scripting options.
Copy link to clipboard
Copied
Have I mentioned SOLID COLOR LAYERS yet?
Not to mention that you could set the Foreground Color via Script and fill …
I recommend that you create a sample file with SOLID COLOR LAYERS and if structure is necessary do that with a Layer set to the appropriate Blend Mode.
Unless you know in which RGB-space those results are they would seem to be pretty much worthless.
Copy link to clipboard
Copied
The only 3 variable I saw are below. I didn't find how to set a layer or foreground to auto fill with an RGB color which is why I am here. Trying to mass produce 50,000 image files is new to me. I couldn't find anything in the adobe photoshop help articles. I know how to manually set a solid colored layer and save it manually, but I am trying to avoid manually setting color and naming each file.
http://help.adobe.com/en_US/Photoshop/11.0/WSfd1234e1c4b69f30ea53e41001031ab64-7414a.html
Pixel Replacement
Text Replacement
For Pixel Replacement variables, set the following options.
Copy link to clipboard
Copied
I am working with Ginostylz on this project. Let me try to put this as best I can:
There are three layers in the photoshop file.
1) Layer 1 sits on top of the other two, and it has a somewhat transparent overlay with some light effects on it on it. This layer gives the colors in the underlying layers the desired effect.
2) Layer 2 is one of two colors we'd like to pull from a CSV file. It can be just a flat color that fills up the whole layer. It has a "hard light" layer mode on it.
3) Layer 3 is the second of two colors we'd like to pull from a CSV file. It can be just a flat color that fills up the whole layer.
In our research with Adobe's help site entitled "creating data driven graphics", it looks like we have two choices, both of which seem way harder than it could/should be.
1) Option 1: Use the "Pixel Replacement" feature to pull the colors in. To do this, we'd have to create 100,000 images with flat colors and then pull them in
2) Option 2: Use the "Visibility" feature to selectively show/hide layers of different colors. To do this, we'd have to create 100,000 layers with flat colors.
What we'd like to be able to do at this point is to simply replace the RGB of layers 2 and 3 using a CSV file and then export to create many images. Is this possible? If not, how would you go about this?
Copy link to clipboard
Copied
Is this possible? If not, how would you go about this?
Quite frankly I practically never use the »data driven graphics«-feature.
In this case a custom Script may be the best way to go, too.
A couple of the more experienced contributors here and over at ps.scripts.com (you could also search for csv-file-related threads there) offer their services professionally – and I think there would be advantages to taking them up on that in this case especially if speed is a concern.
But they are usually also very generous with their advice and help so you may yet get all the advice you need here for free.
Copy link to clipboard
Copied
Edited:
For example:
I have a txt-file with this text:
color1;20;30;40;
color2;60;70;80;
color3;60;50;40;
and a file »testEmboss-psd« open and active in Photoshop with a top-level (meaning it is not in a Group) Solid Color Layer with the name »colorLayer«; the Script at the bottom will get me these:
// 2012, use it at your own risk;
// thanks to xbytor;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var documentName = myDocument.name;
var basename = documentName.match(/(.*)\.[^\.]+$/)[1];
// get path;
try {var documentPath = myDocument.path}
catch (e) {var documentPath = "~/Desktop"};
// psd options;
psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = false;
psdOpts.layers = true;
psdOpts.spotColors = true;
// get file;
if ($.os.search(/windows/i) != -1) {var theFile = File.openDialog ("please select files", "*.txt", false)}
else {var theFile = File.openDialog ("please select files", getFiles, false)};
if (theFile) {
var theText = readPref(theFile);
var theArray = theText.split("\n");
//
try {
var theLayer = myDocument.layers.getByName("colorLayer");
// work through list;
for (var m = 0; m < theArray.length; m++) {
var thisText = theArray
.split(";"); alert (thisText.join("\n\n"));
var theName = thisText[0];
editSolidFill (thisText[1], thisText[2], thisText[3], theLayer);
// save psd;
myDocument.saveAs((new File(documentPath+"/"+basename+"_"+theName+".psd")),psdOpts,true);
}
}
catch (e) {};
};
};
////// function to change solid fill layers //////
function editSolidFill (theL, theA, theB, theLayer) {
app.activeDocument.activeLayer = theLayer;
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idcontentLayer, idOrdn, idTrgt );
desc3.putReference( idnull, ref2 );
var idT = charIDToTypeID( "T " );
var desc4 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc5 = new ActionDescriptor();
var idLmnc = charIDToTypeID( "Lmnc" );
desc5.putDouble( idLmnc, theL );
var idA = charIDToTypeID( "A " );
desc5.putDouble( idA, theA );
var idB = charIDToTypeID( "B " );
desc5.putDouble( idB, theB );
var idLbCl = charIDToTypeID( "LbCl" );
desc4.putObject( idClr, idLbCl, desc5 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc3.putObject( idT, idsolidColorLayer, desc4 );
executeAction( idsetd, desc3, DialogModes.NO );
};
////// read prefs file //////
function readPref (thePath) {
if (File(thePath).exists == true) {
var file = File(thePath);
file.open("r");
file.encoding= 'BINARY';
var theText = new String;
for (var m = 0; m < file.length; m ++) {
theText = theText.concat(file.readch());
};
file.close();
return String(theText)
}
};
////// get psds, tifs and jpgs from files //////
function getFiles (theFile) {
if (theFile.name.match(/\.(txt)$/i)) {
return true
};
};
Copy link to clipboard
Copied
Thank you. I think this script will work, if I could get it to work on my end - having a little problem with that, though.
I took the code you provided and made a .jsx file out of it. I renamed my psd testEmboss-psd (also tried testEmboss.psd - not sure if it mattered). I made a new layer with the name colorLayer and gave it a flat color with the paint bucket tool. I also created a list.txt file with the values, identical to how you have it.
I tried to run the script by going to file>scripts>browse and selecting the .jsx file. It then instantly asks me for a text file, and i open list.txt. The only thing that happens at this point is a white alert box which seems to give me the first line of the txt file (double spaced). Any ideas?
Copy link to clipboard
Copied
Did you OK it… If you don't want the alert then remove the line…
alert (thisText.join("\n\n"));
or comment it out with
//alert (thisText.join("\n\n"));
Copy link to clipboard
Copied
When I hit "Ok", nothing seems to happen.
I tried commenting out the alert, and now nothing happens at all, no alert, nothing. Nothing seemed to happen except the alert before, but now nothing at all seems to happen at all.
Copy link to clipboard
Copied
How often do I need to point out »Solid Color Layers«?
According to your screenshot you seem to have named a normal Layer »colorLayer« and not, as instructed, a Solid Color Layer.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Using "Solid Color" from the "Create new fill or adjustment layer" menu, I got it to work successfully as it did for you.
Now I need to know how to add a second color layer that I can control from a second set of variables in each image. I also need to know how to save as a jpg instead of a psd.
Thank you very much for your help so far!
Copy link to clipboard
Copied
Just add the additional info in the text (like this maybe
color1;20;30;40;color2;50;60;70;
) and get a second Layer by its name (in the case of »colorLayer2« something like
var theOtherLayer = myDocument.layers.getByName("colorLayer2");
), then add the correct line to edit it.
editSolidFill (thisText[5], thisText[6], thisText[7], theOtherLayer);
For figuring out how to save jpgs check out ExtendScript Toolkot’s Help > Object Model Viewer or search for a Script that does a JPG-save or refer to »Photoshop CS5 JavaScript Ref.pdf« and »Photoshop CS5 Scripting Guide.pdf«.
Copy link to clipboard
Copied
It is possible to change the color of a Solid Color Layer via Script and saving (a copy of) that can also be done via Script.
If the angled measurements are intended to be incorporated I think that might also be done with Solid Color Layers with Layer Masks.
Copy link to clipboard
Copied
The scripting part is what is stumping me. Do you have a reading resource for that so I can review it with my programmer and web designer?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now