0

I need to change color of Smart Object Layer in JS script. I found how to change TextLayer, but SmartObjects haven't "textItem" property. Need to change it like Color Overlay works in Photoshop. For example i have this hoodie: enter image description here

I have been selected Compass layer right now and I wanna run my JS script. Then compass should change his color to red (or something else). This compass layer is Smart Object Layer (or Rasterized Image).

Can anyone help me with that? I spend 3 days to find how to do this. Thanks!

7
  • Welcome to GD.SE! Can you elaborate on what your desired result is? As it stands it's rather vague. Are you going to want to change the color to a different color down the road? Why does it need to be a script? A little more insight is needed. Commented Feb 20, 2019 at 16:11
  • Hi @Ovaryraptor ! The result is should be like that i.imgur.com/HJVwxFi.png It should be a script, because I need to change .psd files on background (e.g. move compass 20px to right side and change color to blue) automatically. Commented Feb 20, 2019 at 16:24
  • I still don't see why you need a script for this. Let me clarify, what is your END GOAL? Is this going into a catalog, is it a one-off edit, are you going to have to make alignment and color edits in the future for many colors? Commented Feb 20, 2019 at 18:25
  • If the only goal is to change the color I think it's better to do an Action.
    – LeoNas
    Commented Feb 20, 2019 at 19:33
  • @Ovaryraptor I have a site with t-shirts and wanna give clients opportunity to customize the t-shirt. I have psd file of t-shirt, and need way to change layers in this file. The only thing which can change it, is Photoshop. And I need change layers in psd file, (like colors, positions) then send it to the printer. And only thing I can't do right now - change color on Smart Object using scripting Photoshop. Commented Feb 21, 2019 at 8:59

1 Answer 1

0

This will create a Color Overlay effects with a specific color (red in this example). Modify r, g and b values to the ones you need.

applyColorOverlay(
{
    r: 255,
    g: 0,
    b: 0,
})

function applyColorOverlay(color)
{
    var desc6 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty(charIDToTypeID('Prpr'), charIDToTypeID('Lefx'));
    ref1.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
    desc6.putReference(charIDToTypeID('null'), ref1);
    var desc7 = new ActionDescriptor();
    var desc8 = new ActionDescriptor();
    desc8.putBoolean(charIDToTypeID('enab'), true);
    desc8.putBoolean(stringIDToTypeID('present'), true);
    desc8.putBoolean(stringIDToTypeID('showInDialog'), true);
    desc8.putEnumerated(charIDToTypeID('Md  '), charIDToTypeID('BlnM'), charIDToTypeID('Nrml'));
    var desc9 = new ActionDescriptor();
    desc9.putDouble(charIDToTypeID('Rd  '), color.r);
    desc9.putDouble(charIDToTypeID('Grn '), color.g);
    desc9.putDouble(charIDToTypeID('Bl  '), color.b);
    desc8.putObject(charIDToTypeID('Clr '), charIDToTypeID('RGBC'), desc9);
    desc8.putUnitDouble(charIDToTypeID('Opct'), charIDToTypeID('#Prc'), 100.000000);
    desc7.putObject(charIDToTypeID('SoFi'), charIDToTypeID('SoFi'), desc8);
    desc6.putObject(charIDToTypeID('T   '), charIDToTypeID('Lefx'), desc7);
    executeAction(charIDToTypeID('setd'), desc6, DialogModes.NO);
};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.