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

how o change background color of an image using script?

Guest
Jul 22, 2015 Jul 22, 2015

how o change background color of an image using script?

TOPICS
Actions and scripting
3.1K
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 ,
Jul 22, 2015 Jul 22, 2015

Hi @pb4891,

please explain:

- which scripting language?

- only the background color itself?

- or do you want to fill the canvas of the background layer?

- do you always have a real background layer?

But anyway - try this to change only the background color with javascript:

// create a color of your choice

var BGcolor = new SolidColor();

BGcolor.rgb.red = 0;

BGcolor.rgb.green = 0;

BGcolor.rgb.blue = 255;

// set your color as background color

backgroundColor.rgb.hexValue = BGcolor.rgb.hexValue;

And this will change the color of background layer:

// BGcolor_fillBackgroundLayer.jsx

// https://forums.adobe.com/message/7781601#7781601

// required: an opened document

// fill canvas with blue color - if background layer exists

// regards pixxxelschubser

// create a color of your choice

var BGcolor = new SolidColor();

BGcolor.rgb.red = 0;

BGcolor.rgb.green = 0;

BGcolor.rgb.blue = 255;

// set your color as background color

backgroundColor.rgb.hexValue = BGcolor.rgb.hexValue;

// check if a real background layer exists and fill with your color

var aDoc = app.activeDocument;

var theLayers = aDoc.layers;

aDoc.activeLayer = theLayers[theLayers.length-1];

var aLayer = aDoc.activeLayer;

if (aLayer.isBackgroundLayer) {

    app.activeDocument.selection.fill (backgroundColor, ColorBlendMode.NORMAL, 100, false);

    alert("Done")

    } else {

        // here you could create a new background layer - instead of the alert

        alert ("Sorry, but there is no background layer");

        }

Have fun

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 05, 2015 Aug 05, 2015

To add to this the code, what is need it to search to multiple images that are loaded in Photoshop ?

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
Guest
Aug 12, 2015 Aug 12, 2015
LATEST

Thanks for the code.

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