b/w logo auto change on b/w background

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

yancheng

b/w logo auto change on b/w background

Post by yancheng »

I have a logo one is white one is black to be watermark. so how i can auto change when background if same color or nearly color.
can anyone help me? thanks a lot
photoshop action or script

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

pfaffenbichler

b/w logo auto change on b/w background

Post by pfaffenbichler »

I suppose you could try
• loading the logo’s transparency as a Selection,
• expanding it a bit,
• hiding the logo and
• then evaluating the Selection’s Histogram.
pfaffenbichler

b/w logo auto change on b/w background

Post by pfaffenbichler »

Provided both logos are identical save for the »color« another option might be to use the expanded Selection to
• copy part of the underlying image onto a Layer of its own,
• neutralize it (Hue/Saturation or something else),
• use Filter > Blur > Average,
• use Image > Adjustments > Threshold to get it to either black or white,
• use Image > Adjustments > Invert and
• Clipping Mask it to the logo.

Edit: Something like this
Code: Select all// make black or white layer depending on background;
// 2012; use it at your own risk;
#target photoshop
if (app.documents.length > 0 && app.activeDocument.mode == DocumentMode.RGB) {
var myDoc = app.activeDocument;
var theLayer = myDoc.activeLayer;
// selection;
loadTransparency ();
myDoc.selection.expand(10);
// hide layer;
theLayer.visible = false;
// copy merged;
var idCpyM = charIDToTypeID( "CpyM" );
executeAction( idCpyM, undefined, DialogModes.ALL );
// paste;
var idpast = charIDToTypeID( "past" );
executeAction( idpast, undefined, DialogModes.ALL );
// move new layer up;
var theNewLayer = myDoc.activeLayer;
loadTransparency ();
theNewLayer.move(theLayer, ElementPlacement.PLACEBEFORE);
theNewLayer.desaturate();
theNewLayer.applyAverage();
theNewLayer.threshold(127);
theNewLayer.invert();
myDoc.selection.deselect();
// show layer;
theLayer.visible = true;
theNewLayer.grouped = true;
};
////// load transparency //////
function loadTransparency () {
// =======================================================
var idsetd = charIDToTypeID( "setd" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref2.putProperty( idChnl, idfsel );
    desc3.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idTrsp = charIDToTypeID( "Trsp" );
        ref3.putEnumerated( idChnl, idChnl, idTrsp );
    desc3.putReference( idT, ref3 );
executeAction( idsetd, desc3, DialogModes.NO );
};
jacobolus

b/w logo auto change on b/w background

Post by jacobolus »

If you can make your logo be on a layer which is opaque outside the area of the logo (color irrelevant) and transparent inside, then you can use a layer group of, from bottom to top, (1) a pure white solid color fill layer set to "exclusion" blend mode, (2) a threshhold adjustment layer, (3) your logo layer, with fill opacity set to 0% in the advanced blending options, and "shallow" knockout turned on – it is then used to punch transparency through the other two layers to whatever is outside the group.

If instead your logo is a vector mask or a layer mask, you can again make the group with white solid color layer set to exclusion mode with a threshhold on top, but then you can just directly attach your logo mask to the group.
yancheng

b/w logo auto change on b/w background

Post by yancheng »

sorry, my english not good.

I mean this script or action can automatic to choose the right logo to put on it. If do it one by one then no need to use script, right?

thanks for help, and I keep trying...
yancheng

b/w logo auto change on b/w background

Post by yancheng »

Well done, this is I wanted, you are genius
Thanks so much


pfaffenbichler wrote:Provided both logos are identical save for the »color« another option might be to use the expanded Selection to
• copy part of the underlying image onto a Layer of its own,
• neutralize it (Hue/Saturation or something else),
• use Filter > Blur > Average,
• use Image > Adjustments > Threshold to get it to either black or white,
• use Image > Adjustments > Invert and
• Clipping Mask it to the logo.

Edit: Something like this
Code: Select all// make black or white layer depending on background;
// 2012; use it at your own risk;
#target photoshop
if (app.documents.length > 0 && app.activeDocument.mode == DocumentMode.RGB) {
var myDoc = app.activeDocument;
var theLayer = myDoc.activeLayer;
// selection;
loadTransparency ();
myDoc.selection.expand(10);
// hide layer;
theLayer.visible = false;
// copy merged;
var idCpyM = charIDToTypeID( "CpyM" );
executeAction( idCpyM, undefined, DialogModes.ALL );
// paste;
var idpast = charIDToTypeID( "past" );
executeAction( idpast, undefined, DialogModes.ALL );
// move new layer up;
var theNewLayer = myDoc.activeLayer;
loadTransparency ();
theNewLayer.move(theLayer, ElementPlacement.PLACEBEFORE);
theNewLayer.desaturate();
theNewLayer.applyAverage();
theNewLayer.threshold(127);
theNewLayer.invert();
myDoc.selection.deselect();
// show layer;
theLayer.visible = true;
theNewLayer.grouped = true;
};
////// load transparency //////
function loadTransparency () {
// =======================================================
var idsetd = charIDToTypeID( "setd" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref2.putProperty( idChnl, idfsel );
    desc3.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idTrsp = charIDToTypeID( "Trsp" );
        ref3.putEnumerated( idChnl, idChnl, idTrsp );
    desc3.putReference( idT, ref3 );
executeAction( idsetd, desc3, DialogModes.NO );
};