Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add r/o/y/g/b/i/v to foreground color?

New Here ,
Aug 31, 2013 Aug 31, 2013

hello...

Is there a way to have image/adjustments/color balance affect the current (foreground) color instead of the existing pixels on the layer?

For example-

if my current foreground color is red (in the tools panel), when I paint in my document with a brush, it paints red (obviously).

Now - I want to add a bit of yellow to the current brush/foreground color (which is currently red).

Is there a slider which would allow me to add some more yellow to the foreground color (much like the color balance sliders?)

seems like a simple request, but I haven't been able to find something like this so far..

thanks!!

TOPICS
Actions and scripting
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Aug 31, 2013 Aug 31, 2013

Say what?

Does Select > Color Range not help for what you want?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2013 Aug 31, 2013

Also: Is there a reason why you ask in the Photoshop Scripting Forum and not in the general Photoshop Forum?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2013 Aug 31, 2013

my apologies - I should have posted this in general (I didn't notice)

Unfortunately, the color range isn't what I'm after-

here is a better way to ask my question, and thanks again:

sliders.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 31, 2013 Aug 31, 2013

That dialog can not change the foreground/background color. Have you tried the Window-Color menu( F6 )?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2013 Aug 31, 2013

yes thanks, I've tried the color menu but it only shows R/G/B.. (it's close, though)... but I was hoping for a way to have all 6 sliders (cyan/magenta/yellow/red/green/blue) and just pull them to adjust the foreground/background color.

That said, it doesn't necessarily have to be the same type of dialog or contain sliders, I'm just seraching for a way to do this... I'm not sure Photoshop has the functionality though

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 31, 2013 Aug 31, 2013

This is a bit of a hack but I think it does what you want.

function modifyForegroundColor(){

    var doc = app.activeDocument;

    var currentLayer = doc.activeLayer;

    doc.activeLayer = doc.layers[0];

    var colorLayer = doc.artLayers.add();

    doc.selection.selectAll();

    doc.selection.fill(app.foregroundColor);

    colorBalanceDialog();

    var sample = doc.colorSamplers.add( [ new UnitValue( 10, 'px' ), new UnitValue( 10, 'px' ) ] );

    app.foregroundColor = sample.color;

    sample.remove();

    colorLayer.remove();

    doc.activeLayer = currentLayer;

}

function colorBalanceDialog() {

    var desc = new ActionDescriptor();

    desc.putBoolean( charIDToTypeID('PrsL'), true );

    try{

        executeAction( charIDToTypeID('ClrB'), desc, DialogModes.ALL );

    }catch(e){}

};

if(app.documents.length>0){

    app.activeDocument.suspendHistory('Modify Foreground Color','modifyForegroundColor()');

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2013 Aug 31, 2013

wow Michael - this is excellent - thank you so much!

If I may ask:

after the script has run, it leaves the top layer in the layer stack turned on - is there a way to return the top layer to whatever it was before running the script (on or off)? In this case, I have my top layer turned off, but after the script has executed, the top layer turns on (visible)

also, the 'info' window pops up after running the script - can I omit that part of the script? I am also looking for a way to 'deselect' after the script has run - because the script also selects the entire image boundaries ('marching ants') after it has executed

I've read through the script and am unfortunately unable to determine where

all of the above info has been programmed into it.. I'm looking for the words "top layer" or "deselect" or "info window" or something of that nature so I can attempt to modify it myself - but I don't see anything like that

that said - this is really great, I can't thank you enough

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2013 Aug 31, 2013

update: I have solved how to deselect after the script has run. I have added the following line to the end of Michaels' script:

activeDocument.selection.deselect();

and it works

...now the selection has been deselected after the script executes - just what I wanted.

I'm a total newbie to scripting but it's fun to learn it..

now I need to find out how to close the info window and also leave the top layer's visibility alone... I'll look into it..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 31, 2013 Aug 31, 2013

function modifyForegroundColor(){

    var doc = app.activeDocument;

    var currentLayer = doc.activeLayer;

    var currentVisibility= currentLayer.visible;

    var topLayerVisibility = doc.layers[0].visible;

    doc.activeLayer = doc.layers[0];

    var colorLayer = doc.artLayers.add();

    doc.selection.selectAll();

    doc.selection.fill(app.foregroundColor);

    colorBalanceDialog();

    doc.selection.deselect();

    var sample = doc.colorSamplers.add( [ new UnitValue( 10, 'px' ), new UnitValue( 10, 'px' ) ] );

    app.foregroundColor = sample.color;

    sample.remove();

    colorLayer.remove();

    doc.activeLayer = currentLayer;

    currentLayer.visible = currentVisibility;

    doc.layers[0].visible = topLayerVisibility;

    app.runMenuItem(charIDToTypeID('TglI'));

}

function colorBalanceDialog() {

    var desc = new ActionDescriptor();

    desc.putBoolean( charIDToTypeID('PrsL'), true );

    try{

        executeAction( charIDToTypeID('ClrB'), desc, DialogModes.ALL );

    }catch(e){}

};

if(app.documents.length>0){

    app.activeDocument.suspendHistory('Modify Foreground Color','modifyForegroundColor()');

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2013 Aug 31, 2013

Excellent. Works perfectly - exactly what I was looking for. Wish I could buy you a beer sometime

.. on a sidenote, is there a way to speed up scripts? Some scripts are slower than others, and I've actually come across a few topics involving how to speed them up... I'll search the forums right now and see if there's a way to do it.. thanks again my friend

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 31, 2013 Aug 31, 2013

There are several things that may speed up a script. It depends on what the script does. Sometimes there is nothing that helps. Do you have a specific script that is too slow?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2013 Aug 31, 2013

the specific script is the one in this topic.. (not complaining though, your script is an absolute home run ).. but sometimes it's a little slow to operate.. for example, bringing up the color balance dialog seems to lag, and then after hitting 'ok', it lags when bringing up the info window and then lags again to close it...

I removed the selection/deselect code in the script (it seems to have helped a bit), so there is no longer a selection being selected/deselected ('marching ants') - this speeds it up just a touch.

I'm wondering if there's a way to completely omit the displaying of the info window - this would really speed it up. but (I don't know if the info window is necessary or not)

That said - my overall system is slow at times as well, so that's a factor too.

My guess is that it boils down to removing the info window part of the script (if possible), or add some extra code to speed it up? Lastly, I will also need to evaluate my overall system environment and make sure there isn't anything else slowing everything down (malware, etc.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 31, 2013 Aug 31, 2013

Well as said it is a bit of a hack. It has to create a new layer, bring up the color balance dialog, set a colorSampler, then clean up after itself. I think the info panel pops up because of the colorSampler. You can also get the color of a pixel by making a selection and checking the historgram of the selection. That takes longer than using the color sampler.

I am not sure if there is anything that can be done to speed this up. If you are working with a document that has a large canvas size it may help to select a smaller area to fill with foregroundColor instead of selectAll but adding and removing a large layer is slower than working with a smaller one.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2013 Aug 31, 2013
LATEST

thanks, I will try filling the foreground area into a smaller box and see if that helps. If not, no big deal - this script has already sped up my workflow and made my life a lot easier

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines