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

How to align values of chart images by flip horizontal?

Engaged ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

I receive about 1000 chart images daily that following images are two sample of my images: 

001.jpgUntitled002.jpg 

Now i want to align values of charts using flip horizontal and use photoshop action or script to apply on 1000 daily images like following: 

Video-2023-05-23-195416.gif 

The left side of the chart bars does not need any changes and photoshop action can divide the images into two parts (left side of chart bars - other sides of chart bars) 

next step of action after dividing images, the values on the right side of the chart bars should be selected with Color Range (dark color) 

 

Now i have problem after above step. I must expand selection of values (that i selected by color range) to only left side and selections must extend to the edge of the left border of the layer. 

After extending the selections to the leftmost point of the layer, i can convert each selection to specific layer and every layer can filp horizontal. 

Finally with above steps photoshop action can align all of my images values. 

 

Does anyone have any ideas to solve my problem? 

Please help me in any way you can. If I don't find a solution to this problem, I will lose my job. My only hope is God and this forum and I hope to find a solution for this problem.

TOPICS
Actions and scripting , Windows

Views

6.1K

Translate

Translate

Report

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

correct answers 2 Correct answers

Community Expert , Jun 11, 2023 Jun 11, 2023

edited 2023-06-12 

 

 

// moveNumbersLeftOfBarGraphs
// separate elements in specific graphics, put the bars right and align the numbers on the left;
// 2023, use it at your own risk;
var time1 = Number(timeString());
moveNumbersLeftOfBarGraphs ();
var time2 = Number(timeString());
alert("\nthe script took: "+((time2-time1)/1000)+" seconds\nstart "+time1+"\nend "+time2+"\n\n");
////// move numbers to left of bar graphs //////
function moveNumbersLeftOfBarGraphs () {
if (app.documents.length > 0)
...

Votes

Translate

Translate
Community Expert , Jun 16, 2023 Jun 16, 2023

This should perform at least somewhat faster if you want to give it a try: 

// moveNumbersLeftOfBarGraphs
// separate elements in specific graphics, put the bars right and align the numbers on the left;
// ideally bars and logos should be colorful to make numbers better identifyable;
// 2023, use it at your own risk;
executeAction( stringIDToTypeID( "revert" ), undefined, DialogModes.NO );
var time1 = Number(timeString());
moveNumbersLeftOfBarGraphs ();
var time2 = Number(timeString());
alert("\
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 13, 2023 Jun 13, 2023

Copy link to clipboard

Copied

ESTK Photoshop Scripting can be done in AppleScript, Visual Basic and JavaScript – that’s it. 

And JavaScript is the preferred choice among those three because it is platform-independent. 

Votes

Translate

Translate

Report

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
Engaged ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied


@c.pfaffenbichler wrote:

ESTK Photoshop Scripting can be done in AppleScript, Visual Basic and JavaScript – that’s it. 

And JavaScript is the preferred choice among those three because it is platform-independent. 




Almost all steps have been done to extract values from chart images, but one of the steps I am doing is not very interesting. 

when i want to separate chart images to multiple bars i must use left side of images. 

i can select left side texts by color range tool like following: 

original imageoriginal imageselected left side textsselected left side texts 

but i need a selection like following selection: 
Untitle43534534535d.jpg 

note that i can select one by one but i can't tech it to photoshop action. i must use a automatic way. for example convert color range selection to second selection that i provide. 

If you have any idea for this please share with me. 

i attached sample JPG file.

Votes

Translate

Translate

Report

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 ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

So the original point of the thread is resolved? 

 

I see no realistic option for a »pure« Action to achieve this, again a Script can probably provide a solution. 

Votes

Translate

Translate

Report

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
Engaged ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

quote

So the original point of the thread is resolved? 

 

I see no realistic option for a »pure« Action to achieve this, again a Script can probably provide a solution. 


By @c.pfaffenbichler

yes original point of the thread is resolved. 

only my left side selection not very interesting and maybe create a problem for separate images.

Votes

Translate

Translate

Report

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 ,
Jun 15, 2023 Jun 15, 2023

Copy link to clipboard

Copied

quote

yes original point of the thread is resolved. 

Then please mark the thread as such. 

 

quote

only my left side selection not very interesting and maybe create a problem for separate images.

If the issue is relevant to your workflow it may well not be very interesting but maybe you should still start a new thread and someone else might have time to chime in. 

Votes

Translate

Translate

Report

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
Engaged ,
Jun 15, 2023 Jun 15, 2023

Copy link to clipboard

Copied

quote
If the issue is relevant to your workflow it may well not be very interesting but maybe you should still start a new thread and someone else might have time to chime in. 

By @c.pfaffenbichler

ok - i will create a new conversation for it. tnq very much

Votes

Translate

Translate

Report

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 ,
Jun 16, 2023 Jun 16, 2023

Copy link to clipboard

Copied

This should perform at least somewhat faster if you want to give it a try: 

// moveNumbersLeftOfBarGraphs
// separate elements in specific graphics, put the bars right and align the numbers on the left;
// ideally bars and logos should be colorful to make numbers better identifyable;
// 2023, use it at your own risk;
executeAction( stringIDToTypeID( "revert" ), undefined, DialogModes.NO );
var time1 = Number(timeString());
moveNumbersLeftOfBarGraphs ();
var time2 = Number(timeString());
alert("\nthe script took: "+((time2-time1)/1000)+" seconds\nstart "+time1+"\nend "+time2+"\n\n");
////// move numbers to left of bar graphs //////
function moveNumbersLeftOfBarGraphs () {
if (activeDocument.layers.length > 1 || activeDocument.layers[0].isBackgroundLayer == true) {};
if (app.documents.length > 0) {
// the number of pixels in percent;
var theScale = 200;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.togglePalettes();
var myDocument = app.activeDocument;
if (myDocument.mode != "DocumentMode.RGB") {myDocument.convertProfile ("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, true)};
var theLayer = myDocument.activeLayer;
// resize image;
myDocument.resizeImage (undefined, undefined, 72, ResampleMethod.NONE);
//myDocument.resizeImage (new UnitValue (theScale, "%"), new UnitValue (theScale, "%"), undefined, ResampleMethod.NEARESTNEIGHBOR);
// create path;
loadChannelAsSelection("red", true, false);
loadChannelAsSelection("grain", true, true);
loadChannelAsSelection("blue", true, true);
myDocument.quickMaskMode = true;
useMagicWand2022 ([1,1]);
expandSelection(2);
invertSelection ();
fillWithBlack ("white");
deselect ();
// resize;
applyThreshold(90);
myDocument.resizeImage (new UnitValue (theScale, "%"), new UnitValue (theScale, "%"), undefined, ResampleMethod.NEARESTNEIGHBOR);
myDocument.quickMaskMode = false;
var theHorStart = myDocument.selection.bounds[0];
var thePathIndex = makeWorkPath2 (0.5);
var thePath = collectPathInfoFromDesc2023 (myDocument, thePathIndex[0]);
////////////////////////////////////
myDocument.pathItems[0].deselect();
createBackgroundAndSelectiveColorAdjustmentLayerAndThresholdAdjustmentLayer();
////////////////////////////////////
var lineStartExtremes = getSubPathItemExtremes(thePath[0]);
var theRectanglesPath = [[thePath[0]]];
var theNumbersPath = [[]];
// process subpathitems;
for (var m = 1; m < thePath.length; m++) {
var theExtremes = getSubPathItemExtremes(thePath[m]);
// add subpathitem if within the vertical dimensions;
if (theExtremes[1] >= lineStartExtremes[1] && theExtremes[3] <= lineStartExtremes[3]) {
// if right of suspected bar;
    if (theExtremes[0] > lineStartExtremes[2]) {
        polygonalLassoToolFromPathArray([thePath[m]], false, false);
        var theHisto = histogram ();
// add neutrals to number;
        if (theHisto[0][255] > theHisto[1]*0.5) {
            theNumbersPath[theNumbersPath.length-1].push(thePath[m])
// add colorful to bar;
        } else {
            theRectanglesPath[theRectanglesPath.length - 1].push(thePath[m]);
            lineStartExtremes[2] = Math.max(lineStartExtremes[2], theExtremes[2])
        };
    } else {
        theRectanglesPath[theRectanglesPath.length - 1].push(thePath[m])
        lineStartExtremes[2] = Math.max(lineStartExtremes[2], theExtremes[2])//?
    };
// if further down;
} else {
// new rectangle;
if (theExtremes[1] > lineStartExtremes[3] && theExtremes[3] > lineStartExtremes[3]) {
    if (theExtremes[0] <= theHorStart + 8 && theExtremes[0] >= theHorStart - 8) {
        theRectanglesPath.push([thePath[m]]);
        theNumbersPath.push([])
        lineStartExtremes = theExtremes;
    }
    else {
        polygonalLassoToolFromPathArray([thePath[m]], false, false);
        var theHisto = histogram ();
        if (theHisto[0][255] > theHisto[1]*0.5) {
            theNumbersPath.push([thePath[m]])
        } else {
            theRectanglesPath[theRectanglesPath.length - 1].push(thePath[m])
            lineStartExtremes[2] = Math.max(lineStartExtremes[2], theExtremes[2])//?
        };
    };
//    lineStartExtremes = theExtremes;
} else {
}
};
};
////////////////////////////////////
myDocument.layers[0].remove();
myDocument.layers[0].remove();
myDocument.layers[1].remove();
deselect ();
////////////////////////////////////
// create the layers;
var theRectangles = new Array;
var theNumbers = new Array;
// create layers for the rectangles;
for (var n = 0; n < theRectanglesPath.length; n++) {
polygonalLassoToolFromPathArray(theRectanglesPath[n], false, true);
expandSelection(2);
layerViaCopy ("bar "+(n+1));
deselect ();
theRectangles.push(getLayerIdAndBounds ());
myDocument.activeLayer = theLayer;
};
};
// create layers for the numbers;
for (var o = 0; o < theNumbersPath.length; o++) {
polygonalLassoToolFromPathArray(theNumbersPath[o], false, true);
expandSelection(2);
layerViaCopy ("number "+(o+1));
deselect ();
theNumbers.push(getLayerIdAndBounds ());
myDocument.activeLayer = theLayer;
};
theLayer.visible = false;
////////////////////////////////////
// move layers;
var theHorZero = theRectangles[0][2][0];
var theDist = theNumbers[0][2][0] - theRectangles[0][2][2];
var theWidths = theNumbers.sort(sortArrayByIndexedItem);
var theLongestNumber = theWidths[theWidths.length-1][3];
// move layers;
for (var b = 0; b < theNumbers.length; b++) {
    moveLayer(theNumbers[b][1], theHorZero-theNumbers[b][2][0]+theLongestNumber-theNumbers[b][3], 0)
};
for (var c = 0; c < theRectangles.length; c++) {
    moveLayer(theRectangles[c][1], theLongestNumber+theDist, 0)
};
////////////////////////////////////
// reset;
myDocument.resizeImage (new UnitValue (10000/theScale, "%"), new UnitValue (10000/theScale, "%"), undefined, ResampleMethod.NEARESTNEIGHBOR);
app.preferences.rulerUnits = originalRulerUnits;
app.togglePalettes();
};
////// collect path info from actiondescriptor, indices start at 1, not 0 //////
function collectPathInfoFromDesc2023 (myDocument, thePath) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// based of functions from xbytor’s stdlib;
var idPath = charIDToTypeID( "Path" );
var ref = new ActionReference();
// check if thePath is an index or a dom-path;
if (thePath.constructor == Number) {
ref.putIndex(idPath, thePath)
}
else {
thePath.select();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Path" ), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
};
// get stuff;
var desc = app.executeActionGet(ref);
var pname = desc.getString(cTID('PthN'));
// create new array;
var theArray = new Array;
var pathComponents = desc.getObjectValue(cTID("PthC")).getList(sTID('pathComponents'));
// for subpathitems;
for (var m = 0; m < pathComponents.count; m++) {
    var listKey = pathComponents.getObjectValue(m).getList(sTID("subpathListKey"));
    var operation1 = pathComponents.getObjectValue(m).getEnumerationValue(sTID("shapeOperation"));
    switch (operation1) {
        case 1097098272:
        var operation = 1097098272 //cTID('Add ');
        break;
        case 1398961266:
        var operation = 1398961266 //cTID('Sbtr');
        break;
        case 1231975538:
        var operation = 1231975538 //cTID('Intr');
        break;
        default:
//		case 1102:
        var operation = sTID('xor') //ShapeOperation.SHAPEXOR;
        break;
        };
// for subpathitem’s count;
    for (var n = 0; n < listKey.count; n++) {
        theArray.push(new Array);
        var points = listKey.getObjectValue(n).getList(sTID('points'));
        try {var closed = listKey.getObjectValue(n).getBoolean(sTID("closedSubpath"))}
        catch (e) {var closed = false};
// for subpathitem’s segment’s number of points;
        for (var o = 0; o < points.count; o++) {
            var anchorObj = points.getObjectValue(o).getObjectValue(sTID("anchor"));
            var anchor = [anchorObj.getUnitDoubleValue(sTID('horizontal')), anchorObj.getUnitDoubleValue(sTID('vertical'))];
            var thisPoint = [anchor];
            try {
                var left = points.getObjectValue(o).getObjectValue(cTID("Fwd "));
                var leftDirection = [left.getUnitDoubleValue(sTID('horizontal')), left.getUnitDoubleValue(sTID('vertical'))];
                thisPoint.push(leftDirection)
                }
            catch (e) {
                thisPoint.push(anchor)
                };
            try {
                var right = points.getObjectValue(o).getObjectValue(cTID("Bwd "));
                var rightDirection = [right.getUnitDoubleValue(sTID('horizontal')), right.getUnitDoubleValue(sTID('vertical'))];
                thisPoint.push(rightDirection)
                }
            catch (e) {
                thisPoint.push(anchor)
                };
            try {
                var smoothOr = points.getObjectValue(o).getBoolean(cTID("Smoo"));
                thisPoint.push(smoothOr)
                }
            catch (e) {thisPoint.push(false)};
            theArray[theArray.length - 1].push(thisPoint);
            };
        theArray[theArray.length - 1].push(closed);
        theArray[theArray.length - 1].push(operation);
        };
    };
// by xbytor, thanks to him;
function cTID (s) { return cTID[s] || cTID[s] = app.charIDToTypeID(s); };
function sTID (s) { return sTID[s] || sTID[s] = app.stringIDToTypeID(s); };
// reset;
app.preferences.rulerUnits = originalRulerUnits;
return theArray;
};
////// delete path by id //////
function deletePath (theID) {
var desc32 = new ActionDescriptor();
    var ref9 = new ActionReference();
    ref9.putIndex ( stringIDToTypeID( "path" ), theID );
    desc32.putReference( stringIDToTypeID( "null" ), ref9 );
executeAction( stringIDToTypeID( "delete" ), desc32, DialogModes.NO );
};
////// load path as selection //////
function loadPathAsSelection (theIndex) {
    var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
    desc1.putReference( charIDToTypeID( "null" ), ref1 );
        var ref2 = new ActionReference();
        ref2.putIndex( charIDToTypeID( "Path" ), theIndex );
    desc1.putReference( charIDToTypeID( "T   " ), ref2 );
    desc1.putInteger( charIDToTypeID( "Vrsn" ), 1 );
    desc1.putBoolean( stringIDToTypeID( "vectorMaskParams" ), true );
executeAction( charIDToTypeID( "setd" ), desc1, DialogModes.NO );
};
////// determine selected path //////
function selectedPath2020 () {
try {
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID("property"), stringIDToTypeID("targetPathIndex")); 
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var docDesc = executeActionGet(ref);
var theIndex = docDesc.getInteger(stringIDToTypeID("targetPathIndex"))+1;
//
var ref = new ActionReference();
ref.putIndex( charIDToTypeID("Path"), theIndex); 
var pathDesc = executeActionGet(ref);
var theKind = pathDesc.getEnumerationValue(stringIDToTypeID("kind"));
var theName = pathDesc.getString(stringIDToTypeID("pathName"));
//
return [theIndex, theKind, theName];
}
catch (e) {return undefined}
};
////// make work path from selection //////
function makeWorkPath2 (theTolerance) {
var idPath = charIDToTypeID( "Path" );
var idmake = stringIDToTypeID( "make" );
var idFrom = charIDToTypeID( "From" );
var idnull = stringIDToTypeID( "null" );
// =======================================================
var desc5 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putClass( idPath );
desc5.putReference( idnull, ref3 );
var ref4 = new ActionReference();
ref4.putProperty( charIDToTypeID( "csel" ), charIDToTypeID( "fsel" ) );
desc5.putReference( idFrom, ref4 );
desc5.putUnitDouble( charIDToTypeID( "Tlrn" ), charIDToTypeID( "#Pxl" ), theTolerance );
executeAction( idmake, desc5, DialogModes.NO );
// =======================================================
var desc7 = new ActionDescriptor();
    var ref3 = new ActionReference();
    ref3.putClass( idPath );
desc7.putReference( idnull, ref3 );
var idfrom = stringIDToTypeID( "from" );
    var ref4 = new ActionReference();
    ref4.putProperty( idPath, stringIDToTypeID( "workPath" ) );
desc7.putReference( idFrom, ref4 );
desc7.putString( stringIDToTypeID( "name" ), Math.random() );
executeAction( idmake, desc7, DialogModes.NO );
try {
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID("property"), stringIDToTypeID("targetPathIndex")); 
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var docDesc = executeActionGet(ref);
var theIndex = docDesc.getInteger(stringIDToTypeID("targetPathIndex"))+1;
return [theIndex/*, theKind, theName*/];
}
catch (e) {return undefined}
};
////// load layer mask //////
function loadChannelAsSelection1(theName, theInvert, theIntersect) {
if (theIntersect == false ||  theIntersect == undefined) {var idinterfaceWhite = charIDToTypeID( "setd" )}
else {var idinterfaceWhite = stringIDToTypeID( "interfaceWhite" )};
//    alert (typeIDToStringID(idinterfaceWhite));
try {
    var idchannel = stringIDToTypeID( "channel" );
    var desc70 = new ActionDescriptor();
    var ref9 = new ActionReference();
    ref9.putProperty( idchannel, stringIDToTypeID( "selection" ) );
desc70.putReference( stringIDToTypeID( "null" ), ref9 );
    var ref10 = new ActionReference();
    ref10.putEnumerated( idchannel, idchannel, stringIDToTypeID( theName ) );
desc70.putReference( stringIDToTypeID( "to" ), ref10 );
desc70.putBoolean(charIDToTypeID("Invr"), theInvert);
executeAction( idinterfaceWhite, desc70, DialogModes.NO );
//    executeAction( stringIDToTypeID( "set" ), desc70, DialogModes.NO );
} catch (_error) {alert (_error)}
};
////// function to get the date //////
function timeString () {
var now = new Date();
return now.getTime()
};
////// 
function deselect () {
var desc5 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
desc5.putReference( stringIDToTypeID( "null" ), ref1 );
desc5.putEnumerated( stringIDToTypeID( "to" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "none" ) );
executeAction( stringIDToTypeID( "set" ), desc5, DialogModes.NO );
};
////// x //////
function getSubPathItemExtremes (theArray) {
    var theX1 = theArray[0][0][0];
    var theX2 = theArray[0][0][0];
    var theY1 = theArray[0][0][1];
    var theY2 = theArray[0][0][1];
for (var m = 1; m < theArray.length - 2; m++) {
    var theX1 = Math.min(theX1, theArray[m][0][0]);
    var theX2 = Math.max(theX2, theArray[m][0][0]);
    var theY1 = Math.min(theY1, theArray[m][0][1]);
    var theY2 = Math.max(theY2, theArray[m][0][1]);
    var theWidth = theX2 - theX1;
    var theHeight = theY2 - theY1;
    //alert ("number "+m+"\n"+theValue+"\n"+theWidth+"___"+theHeight)
};
return [theX1, theY1, theX2, theY2, theWidth, theHeight]
};
////// layer via copy //////
function layerViaCopy (theName) {
// layer via copy;
executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );
    var desc5 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated( stringIDToTypeID( "layer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
    desc5.putReference( stringIDToTypeID( "null" ), ref1 );
        var desc6 = new ActionDescriptor();
        desc6.putString( stringIDToTypeID( "name" ), theName );
    desc5.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "layer" ), desc6 );
executeAction( stringIDToTypeID( "set" ), desc5, DialogModes.NO );
};
////// apply threshold //////
function applyThreshold (theValue) {
var desc232 = new ActionDescriptor();
desc232.putInteger( stringIDToTypeID( "level" ), theValue );
executeAction( stringIDToTypeID( "thresholdClassEvent" ), desc232, DialogModes.NO );
};
////// load channel as selection //////
function loadChannelAsSelection(theName, theInvert, theAdd) {  
try {
var idchannel = stringIDToTypeID( "channel" );
if (theAdd == false || theAdd == undefined) {
    var desc70 = new ActionDescriptor();
    var ref9 = new ActionReference();
    ref9.putProperty( idchannel, stringIDToTypeID( "selection" ) );
desc70.putReference( stringIDToTypeID( "null" ), ref9 );
    var ref10 = new ActionReference();
    ref10.putEnumerated( idchannel, idchannel, stringIDToTypeID( theName ) );
desc70.putReference( stringIDToTypeID( "to" ), ref10 );
desc70.putBoolean(charIDToTypeID("Invr"), theInvert);
executeAction( stringIDToTypeID( "set" ), desc70, DialogModes.NO );
} else {
    var desc221 = new ActionDescriptor();
        var ref5 = new ActionReference();
        ref5.putEnumerated( idchannel, idchannel, stringIDToTypeID(theName) );
        desc221.putReference( stringIDToTypeID( "null" ), ref5 );
desc221.putBoolean(charIDToTypeID("Invr"), theInvert);
        var ref6 = new ActionReference();
        ref6.putProperty( idchannel, stringIDToTypeID( "selection" ) );
    desc221.putReference( stringIDToTypeID( "to" ), ref6 );
executeAction( stringIDToTypeID( "add" ), desc221, DialogModes.NO );
}
} catch (_error) {alert (_error)}
};
////// make a rectangular selection //////
function rectangularSelection (x1, y1, x2, y2, theAdd) {
if (theAdd == false || theAdd == undefined) {var idset = stringIDToTypeID( "set" )}
else {var idset = stringIDToTypeID( "addTo" )};
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
var desc16 = new ActionDescriptor();
        var ref2 = new ActionReference();
        ref2.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
    desc16.putReference( stringIDToTypeID( "null" ), ref2 );
        var desc17 = new ActionDescriptor();
        desc17.putUnitDouble( stringIDToTypeID( "top" ), idpixelsUnit, y1 );
        desc17.putUnitDouble( stringIDToTypeID( "left" ), idpixelsUnit, x1 );
        desc17.putUnitDouble( stringIDToTypeID( "bottom" ), idpixelsUnit, y2 );
        desc17.putUnitDouble( stringIDToTypeID( "right" ), idpixelsUnit, x2 );
    desc16.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "rectangle" ), desc17 );
    if(theAdd == true) desc16.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );
executeAction( idset, desc16, DialogModes.NO );
};
////// polygonal lasso tool //////
function polygonalLassoTool (theArray, theSubtract, theAdd) {
if (theSubtract == false || theSubtract == undefined) {var idset = stringIDToTypeID( "set" )}
else {var idset = stringIDToTypeID( "subtractFrom" )};
if (theAdd == true) {var idset = stringIDToTypeID( "addTo" )};
    var desc15 = new ActionDescriptor();
        var ref2 = new ActionReference();
        ref2.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
    desc15.putReference( stringIDToTypeID( "null" ), ref2 );
        var desc16 = new ActionDescriptor();
            var list2 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
                var desc17 = new ActionDescriptor();
                var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
                desc17.putUnitDouble( stringIDToTypeID( "horizontal" ), idpixelsUnit, theArray[m][0] );
                desc17.putUnitDouble( stringIDToTypeID( "vertical" ), idpixelsUnit, theArray[m][1] );
            list2.putObject( stringIDToTypeID( "paint" ), desc17 );
};
        desc16.putList( stringIDToTypeID( "points" ), list2 );
    desc15.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "polygon" ), desc16 );
    var idantiAlias = stringIDToTypeID( "antiAlias" );
    desc15.putBoolean( idantiAlias, false );
executeAction( idset, desc15, DialogModes.NO );
};
////// expand selection //////
function expandSelection (theValue) {
    var idExpn = charIDToTypeID( "Expn" );
        var desc5 = new ActionDescriptor();
        var idBy = charIDToTypeID( "By  " );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc5.putUnitDouble( idBy, idPxl, theValue );
   executeAction( idExpn, desc5, DialogModes.NO );
};
////// get active layer’s id //////
function getLayerIdAndBounds () {
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
    var layerDesc = executeActionGet(ref);
    var theName = layerDesc.getString(stringIDToTypeID('name'));
    var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));
    var theBounds = layerDesc.getObjectValue(stringIDToTypeID("bounds"));
    var theseBounds = [theBounds.getUnitDoubleValue(stringIDToTypeID("left")), theBounds.getUnitDoubleValue(stringIDToTypeID("top")), theBounds.getUnitDoubleValue(stringIDToTypeID("right")), theBounds.getUnitDoubleValue(stringIDToTypeID("bottom"))];
    var theWidth = theseBounds[2]-theseBounds[0];
    var theHeight = theseBounds[3]-theseBounds[1];
    return [theName, theID, theseBounds, theWidth, theHeight]
};
////// move layer on canvas //////
function moveLayer (theID, hor, ver) {
selectLayerByID(theID, false);
    var desc77 = new ActionDescriptor();
    var ref38 = new ActionReference();
    var idlayer = stringIDToTypeID( "layer" );
    ref38.putEnumerated( idlayer, stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ));
desc77.putReference( stringIDToTypeID( "null" ), ref38 );
var idto = stringIDToTypeID( "to" );
    var desc78 = new ActionDescriptor();
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc78.putUnitDouble( stringIDToTypeID( "horizontal" ), idpixelsUnit, hor );
    desc78.putUnitDouble( stringIDToTypeID( "vertical" ), idpixelsUnit, ver );
desc77.putObject( idto, stringIDToTypeID( "offset" ), desc78 );
executeAction( stringIDToTypeID( "move" ), desc77, DialogModes.NO );
};
////// based on code by mike hale, via paul riggott //////
function selectLayerByID(id,add){ 
add = undefined ? add = false:add 
var ref = new ActionReference();
    ref.putIdentifier(charIDToTypeID("Lyr "), id);
    var desc = new ActionDescriptor();
    desc.putReference(charIDToTypeID("null"), ref );
        if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) ); 
        desc.putBoolean( charIDToTypeID( "MkVs" ), false ); 
    try{
    executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
}catch(e){
alert(e.message); 
}
};
////// sort a double array, thanks to sam, http://www.rhinocerus.net/forum/lang-javascript/ //////
function sortArrayByIndexedItem(a,b) {
var theIndex = 3;
if (a[theIndex]<b[theIndex]) return -1;
if (a[theIndex]>b[theIndex]) return 1;
return 0;
};
//////
function createBackgroundAndSelectiveColorAdjustmentLayerAndThresholdAdjustmentLayer() {
// =======================================================
var desc5 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass( stringIDToTypeID( "layer" ) );
desc5.putReference( stringIDToTypeID( "null" ), ref1 );
executeAction( stringIDToTypeID( "make" ), desc5, DialogModes.NO );
// =======================================================
var desc7 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putProperty( charIDToTypeID( "Clr " ), charIDToTypeID( "Clrs" ) );
desc7.putReference( charIDToTypeID( "null" ), ref2 );
executeAction( charIDToTypeID( "Rset" ), desc7, DialogModes.NO );
// =======================================================
var desc10 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putClass( stringIDToTypeID( "backgroundLayer" ) );
desc10.putReference( stringIDToTypeID( "null" ), ref3 );
var ref4 = new ActionReference();
ref4.putEnumerated( stringIDToTypeID( "layer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc10.putReference( stringIDToTypeID( "using" ), ref4 );
executeAction( stringIDToTypeID( "make" ), desc10, DialogModes.NO );
// =======================================================
var desc7 = new ActionDescriptor();
var ref5 = new ActionReference();
ref5.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Frwr" ) );
desc7.putReference( charIDToTypeID( "null" ), ref5 );
desc7.putBoolean( charIDToTypeID( "MkVs" ), false );
executeAction( charIDToTypeID( "slct" ), desc7, DialogModes.NO );
// =======================================================
var desc19 = new ActionDescriptor();
var ref6 = new ActionReference();
ref6.putClass( stringIDToTypeID( "adjustmentLayer" ) );
desc19.putReference( stringIDToTypeID( "null" ), ref6 );
var desc20 = new ActionDescriptor();
    var desc21 = new ActionDescriptor();
    desc21.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindDefault" ) );
var idselectiveColor = stringIDToTypeID( "selectiveColor" );
desc20.putObject( stringIDToTypeID( "type" ), idselectiveColor, desc21 );
var idadjustmentLayer = stringIDToTypeID( "adjustmentLayer" );
desc19.putObject( stringIDToTypeID( "using" ), stringIDToTypeID( "adjustmentLayer" ), desc20 );
executeAction( stringIDToTypeID( "make" ), desc19, DialogModes.NO );
// =======================================================
var idcolors = stringIDToTypeID( "colors" );
var idcolorCorrection = stringIDToTypeID( "colorCorrection" );
var desc137 = new ActionDescriptor();
var ref18 = new ActionReference();
ref18.putEnumerated( stringIDToTypeID( "adjustmentLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc137.putReference( stringIDToTypeID( "null" ), ref18 );
var desc138 = new ActionDescriptor();
    var list12 = new ActionList();
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "magenta" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
        list12.putObject( idcolorCorrection, desc139 );
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "reds" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
        list12.putObject( idcolorCorrection, desc139 );
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "yellows" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
        list12.putObject( idcolorCorrection, desc139 );
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "greens" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
        list12.putObject( idcolorCorrection, desc139 );
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "blues" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
        list12.putObject( idcolorCorrection, desc139 );
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "cyans" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
        list12.putObject( idcolorCorrection, desc139 );
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "whites" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), -100.000000 );
        list12.putObject( idcolorCorrection, desc139 );
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "neutrals" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), -100.000000 );
        list12.putObject( idcolorCorrection, desc139 );
        var desc139 = new ActionDescriptor();
        desc139.putEnumerated( idcolors, idcolors, stringIDToTypeID( "blacks" ) );
        desc139.putUnitDouble( stringIDToTypeID( "black" ), stringIDToTypeID( "percentUnit" ), -100.000000 );
    list12.putObject( idcolorCorrection, desc139 );
desc138.putList( idcolorCorrection, list12 );
desc138.putEnumerated( stringIDToTypeID( "method" ), stringIDToTypeID( "correctionMethod" ), stringIDToTypeID( "absolute" ) );
var idselectiveColor = stringIDToTypeID( "selectiveColor" );
desc137.putObject( stringIDToTypeID( "to" ), idselectiveColor, desc138 );
executeAction( stringIDToTypeID( "set" ), desc137, DialogModes.NO );
// =======================================================
var desc211 = new ActionDescriptor();
var ref25 = new ActionReference();
ref25.putClass( stringIDToTypeID( "adjustmentLayer" ) );
desc211.putReference( stringIDToTypeID( "null" ), ref25 );
var desc212 = new ActionDescriptor();
    var desc213 = new ActionDescriptor();
    desc213.putInteger( stringIDToTypeID( "level" ), 220 );
var idthresholdClassEvent = stringIDToTypeID( "thresholdClassEvent" );
desc212.putObject( stringIDToTypeID( "type" ), idthresholdClassEvent, desc213 );
var idadjustmentLayer = stringIDToTypeID( "adjustmentLayer" );
desc211.putObject( stringIDToTypeID( "using" ), idadjustmentLayer, desc212 );
executeAction( stringIDToTypeID( "make" ), desc211, DialogModes.NO );

};
////// get histogram //////
function histogram () {
try {    
    var desc4 = new ActionDescriptor();
    var ref1 = new ActionReference();
    var idchannel = stringIDToTypeID( "channel" );
    ref1.putEnumerated( idchannel, idchannel, stringIDToTypeID( "RGB" ) );
desc4.putReference( stringIDToTypeID( "null" ), ref1 );
executeAction( stringIDToTypeID( "select" ), desc4, DialogModes.NO );
} catch (e) {};
    var ref = new ActionReference();
    ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("histogram"));
    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var docDesc = executeActionGet(ref);
    var list = docDesc.getList(stringIDToTypeID("histogram"));
    var theArray = new Array;
    var theTotal = 0;
    for (var i = 0; i < list.count; i++) {
        var d = list.getInteger(i);
        theArray.push(d);
        theTotal = theTotal+d;
        };
    return [theArray, theTotal];
    };
////// x //////
function polygonalLassoToolFromPathArray (theArray, theSubtract, theAdd) {
for (var a = 0; a < theArray.length; a++) {
    var thisOne = theArray[a];
    var thisArray = new Array;
    for (var k = 0; k < thisOne.length-2; k++){
        thisArray.push(thisOne[k][0])
    };
    polygonalLassoTool(thisArray, theSubtract, theAdd);
    };
};
////// use magic wand tool //////
function useMagicWand2022 (theCoord) {
var idnull = charIDToTypeID( "null" );
var idPxl = charIDToTypeID( "#Pxl" );
// select tool;
    var desc2 = new ActionDescriptor();
        var ref2 = new ActionReference();
        ref2.putClass( stringIDToTypeID( "magicWandTool" ) );
    desc2.putReference( idnull, ref2 );
    desc2.putBoolean( stringIDToTypeID( "dontRecord" ), true );
    desc2.putBoolean( stringIDToTypeID( "forceNotify" ), true );
executeAction( charIDToTypeID( "slct" ), desc2, DialogModes.NO );
// apply tool;
    var desc2 = new ActionDescriptor();
        var ref2 = new ActionReference();
        ref2.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
    desc2.putReference( idnull, ref2 );
        var desc3 = new ActionDescriptor();
        desc3.putUnitDouble( charIDToTypeID( "Hrzn" ), idPxl, theCoord[0] );
        desc3.putUnitDouble( charIDToTypeID( "Vrtc" ), idPxl, theCoord[1] );
    desc2.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Pnt " ), desc3 );
    desc2.putInteger( charIDToTypeID( "Tlrn" ), 30 );
    desc2.putBoolean( charIDToTypeID( "AntA" ), true );
    desc2.putBoolean( stringIDToTypeID("merged"), true);
executeAction( charIDToTypeID( "setd" ), desc2, DialogModes.NO );
};
////// fill black //////
function fillWithBlack (theColor) {
try {
var desc20 = new ActionDescriptor();
desc20.putEnumerated( stringIDToTypeID( "using" ), stringIDToTypeID( "fillContents" ), stringIDToTypeID( theColor ) );
desc20.putUnitDouble( stringIDToTypeID( "opacity" ), stringIDToTypeID( "percentUnit" ), 100.000000 );
desc20.putEnumerated( stringIDToTypeID( "mode" ), stringIDToTypeID( "blendMode" ), stringIDToTypeID( "normal" ) );
executeAction( stringIDToTypeID( "fill" ), desc20, DialogModes.NO );
} catch (e) {}
};
////// invert selection //////
function invertSelection () {
// =======================================================
executeAction( charIDToTypeID( "Invs" ), undefined, DialogModes.NO );
};

Votes

Translate

Translate

Report

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
Engaged ,
Jun 16, 2023 Jun 16, 2023

Copy link to clipboard

Copied

yes, it optimized to maximum 10 second

Votes

Translate

Translate

Report

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 ,
Jun 16, 2023 Jun 16, 2023

Copy link to clipboard

Copied

Maybe one could optimize it further … 

 

I hope at the current speed it is at least usable. 

Votes

Translate

Translate

Report

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
Engaged ,
Jun 16, 2023 Jun 16, 2023

Copy link to clipboard

Copied

I tried your updated script with following sample but idk why one of logos not removed: 
Untitle5435345345d.jpg

Votes

Translate

Translate

Report

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 ,
Jun 17, 2023 Jun 17, 2023

Copy link to clipboard

Copied

It is black/white so it is not »recognized« as a logo or part of the bar. 

Votes

Translate

Translate

Report

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
Engaged ,
Jun 17, 2023 Jun 17, 2023

Copy link to clipboard

Copied

quote

It is black/white so it is not »recognized« as a logo or part of the bar. 


By @c.pfaffenbichler

yes but in previous version of your script it removed!

Votes

Translate

Translate

Report

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 ,
Jun 17, 2023 Jun 17, 2023

Copy link to clipboard

Copied

Are you sure? 

I can’t remember changing anything in the Script that should affect the distinction of numbers and bars/logos … 

 

Was that graphic part of the original sample set? Otherwise could you provide it? 

The original set of samples included graphics with a certain variety (bars and numbers, bars and logos and numbers, bars with integrated logos or flags and numbers, …) so it may be impossible to process them all with one Script. 

 

Ultimately I think you will have to decide if cleaning up this misidentification is worth the speed gains or not. 

What percentage (roughly) of the graphics do include black logos that get misatributed?

Votes

Translate

Translate

Report

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
Engaged ,
Jun 17, 2023 Jun 17, 2023

Copy link to clipboard

Copied

quote

Are you sure? 

I can’t remember changing anything in the Script that should affect the distinction of numbers and bars/logos … 

 

Was that graphic part of the original sample set? Otherwise could you provide it? 

The original set of samples included graphics with a certain variety (bars and numbers, bars and logos and numbers, bars with integrated logos or flags and numbers, …) so it may be impossible to process them all with one Script. 

 

Ultimately I think you will have to decide if cleaning up this misidentification is worth the speed gains or not. 

What percentage (roughly) of the graphics do include black logos that get misatributed?


By @c.pfaffenbichler

oh no 

in some samples that i provided to you there are many logos that are black/white like following: 

Untitled34534534535.jpg 

i attach this png sample to my post here. 

Of course, I will put another method in the form of an action file here, which you can run on attached JPG file. please check my method that maybe is better and if it possible improve it. 

my atn file for run on tt22.jpg : https://drive.google.com/file/d/13ixMJ0Iw8p4mtbNJUvvLHuED4jHAdP1V

Votes

Translate

Translate

Report

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 ,
Jun 18, 2023 Jun 18, 2023

Copy link to clipboard

Copied

I cannot run the Action as it seems the Scripts used in the Action were not located in the Presets/Scripts-Folder but selected manually. 

Screenshot 2023-06-18 at 14.47.55.png

 

Ultimately I think you should try to consolidate the Scripts as much as possible and move as much as possible from the Action into Script/s. 

But this depends on how comfortable you are with Scripting yet and if an Action does what you need (and the time it takes is acceptable) then it is perfectly legitimate to stick with an Action/Script-combination. 

 

Discerning black numbers and black logos was, if I remember correctly, part of the problem in the earlier thread of yours. 

As far as Photoshop automation is concerened there are neither numbers nor logos nor bars in the images – just pixels.*

If you can think of some way to unequivocally distinguish the black logos from the numbers by a plain, quantifyable property it might be able to automate, but I am not optimistic in that regard. 

 

*: Actually Photoshop appears to have at least some access to OCR (see Type > Match Font) and other, AI-based, »object-recognition«-features but for automation those appear to be irrelevant at current. 

Votes

Translate

Translate

Report

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
Engaged ,
Jun 18, 2023 Jun 18, 2023

Copy link to clipboard

Copied

quote

Ultimately I think you should try to consolidate the Scripts as much as possible and move as much as possible from the Action into Script/s. 

But this depends on how comfortable you are with Scripting yet and if an Action does what you need (and the time it takes is acceptable) then it is perfectly legitimate to stick with an Action/Script-combination. 

By @c.pfaffenbichler

yes i want to share you my action mthods as javascript format but i have following problem: 
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-remove-option-window-from-this...

Votes

Translate

Translate

Report

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
Engaged ,
Jul 02, 2023 Jul 02, 2023

Copy link to clipboard

Copied

quote

I


By @c.pfaffenbichler

can you tell me what is your solution for following selection? 

Untitl5435345345d.jpg 

in above i want select to numbers in unified. the selection of numbers should not be merged with the selection of logos. 

in above example if i expand selection 2 more then selection of numbers will be integrated but the selection of some logos will be merged with the selection of some numbers. 

Votes

Translate

Translate

Report

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 ,
Jul 03, 2023 Jul 03, 2023

Copy link to clipboard

Copied

In this case you would need to find another property that can be used to distinguish »numbers« and »logos«. 

Possible options might be the width of the »strokes« (the lines of the logo being a bit thicker) or the height (but I think in a previous example the height-difference was very small for some logo/s when the descender of the comma is factored in). 

 

I am not optimistic that you will be able to fully automate these approaches to produce reliable results. 

Votes

Translate

Translate

Report

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
Engaged ,
Jul 03, 2023 Jul 03, 2023

Copy link to clipboard

Copied

quote

In this case you would need to find another property that can be used to distinguish »numbers« and »logos«. 

Possible options might be the width of the »strokes« (the lines of the logo being a bit thicker) or the height (but I think in a previous example the height-difference was very small for some logo/s when the descender of the comma is factored in). 

 

I am not optimistic that you will be able to fully automate these approaches to produce reliable results. 


By @c.pfaffenbichler

0abb354e-d6af-48ed-804c-e357bab3d4d2.gif

or maybe can use »flip vertically« and »minimum filter«.

Votes

Translate

Translate

Report

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
Engaged ,
Jul 03, 2023 Jul 03, 2023

Copy link to clipboard

Copied

quote

I


By @c.pfaffenbichler

The script below is my final method that probably the general method I use will work on all chart images, even in cases where the logos are the same color as the values: 

https://drive.google.com/file/d/1nyZLW9eNiapdBZ3mwPlhtMIoLOKpipok/view?usp=sharing

 

The only problem that it have is that it is long and takes a long time to complete. 

If it possible plz check my super beginner method and provide ideas to improve it. 

note that my script is on step-by-step mode and replace following lines in »main.jsx« with path of zip file sub-scripts: 

Line 54452

Line 54617

Line 54722
Line 55638
Line 55690

Votes

Translate

Translate

Report

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 ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

The Scipt fails at line 55115 here (see screenshot). 

 

• You seem to waste many lines by wrapping each individual move or select etc. into a function of its own instead of using one function that takes the necessary variables as input (the name or index of the layer that is to be affected for example and the amount of the movement) and using that repeatedly.

How often is »Layer Via Copy« present as a function of its own? 

• The function step6 alone seems to account for tens of thousands of lines of code … by setting the points individually in code instead of handling the point-corrdinate-arrays with a for clause for example. 

 

These points might not make a (lot of) difference with regard to running-time but to me it makes this Script too hard to read. 

 

Screenshot 2023-07-04 at 13.41.23.png

Votes

Translate

Translate

Report

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
Engaged ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

quote

The Scipt fails at line 55115 here (see screenshot). 


By @c.pfaffenbichler

I don't write this script. I only record my method in action format and then convert it to script and share with you. I only want to you understand my method. 

I don't know why you say get error with my script. When you see the following test, you will notice that the script works perfectly: 

a1b2cc09-fa3e-4752-833d-8e688e7cee00.gif 

If i share you ATN file then you can't set sub-scripts in action file. 

My method is to first convert the chart images into separate bars using the left side. after that, I try to select right sides numerical values in unified by flipping vertical all the separated parts and using the color range tool. Finally, I add the white parts on the right side of the numerical values to the color range selection using the magic wand tool. In fact, I try to select the entire right side of the numerical values along with the numerical values themselves and at last flip horizontal to right.

Votes

Translate

Translate

Report

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
Engaged ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

quote

T


By @c.pfaffenbichler

Untitled5646456.jpg 

Need something to convert above selection to following selection and flip rightmost selections in each line to the right:  Untitled4534534535.jpg

 

with this method even logos that have same color to values will remove 🙂 

 

Votes

Translate

Translate

Report

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 ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

»Flip_only_selected_layers_horizontal.jsx« uses DOM-code for the flipping, using AM-code instead can speed this up. 

You can use the Script below to test the speed difference. (Here the DOM version takes about 0.283 seconds, the AM version about 0.149 seconds.)

It seems possible, but it is not guaratneed, that abandoning Actions and recreating the whole process as one meaningful Script might provide some additional speed gains. And even if they are small they might matter at volume. 

 

As for your new idea I am not interested; maybe you should start a new thread and someone else might take an interest in the task. 

 

Screenshot 2023-07-05 at 09.00.14.png

#target photoshop
executeAction( stringIDToTypeID( "revert" ), undefined, DialogModes.NO );
var time1 = Number(timeString());
test1 ();
var time2 = Number(timeString());
executeAction( stringIDToTypeID( "revert" ), undefined, DialogModes.NO );
var time3 = Number(timeString());
test2 ();
var time4 = Number(timeString());
alert("\nscript1 took: "+((time2-time1)/1000)+" seconds\nstart "+time1+"\nend "+time2+"\nscript2 took: "+((time4-time3)/1000)+" seconds\nstart "+time3+"\nend "+time4+"\n\n");
/* Start Process selected layers - from jazz-y */
function test1 () {
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
    sel = new ActionReference();

for (var i = 0; i < lrs.count; i++) {
    sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
    (r = new ActionReference()).putIdentifier(s2t('layer'), p);
    (d = new ActionDescriptor()).putReference(s2t("target"), r);
    executeAction(s2t('select'), d, DialogModes.NO);
/* End Process selected layers - from jazz-y */

// Your code here:
    if (activeDocument.activeLayer.isBackgroundLayer == false) {
        var vis = activeDocument.activeLayer.visible;                                         //save whether the layer was visible or not
        activeDocument.activeLayer.visible = true;                                            //set to visible so the layer is editable
        activeDocument.activeLayer.resize(-100, undefined, AnchorPosition.MIDDLECENTER);      //flip the layer
        activeDocument.activeLayer.visible = vis;                                             //set the visibility back to what it was before editing
    }
    else {
        activeDocument.activeLayer.visible = true;                                            //set to visible so the layer is editable
        activeDocument.activeLayer.isBackgroundLayer = false;                                 //transform background layer into normal layer
        activeDocument.activeLayer.resize(-100, undefined, AnchorPosition.MIDDLECENTER);      //flip it
        activeDocument.activeLayer.isBackgroundLayer = true;                                  //turn back into backgorund layer
    }
}
};
// version with less dom code;
function test2 () {
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
    sel = new ActionReference();

for (var i = 0; i < lrs.count; i++) {
    sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
var ref = new ActionReference();
ref.putIdentifier( charIDToTypeID( "Lyr " ), p);
var layerDesc = executeActionGet(ref);
var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
var theVisibility = layerDesc.getBoolean(stringIDToTypeID('visible'));
    (r = new ActionReference()).putIdentifier(s2t('layer'), p);
    (d = new ActionDescriptor()).putReference(s2t("target"), r);
    executeAction(s2t('select'), d, DialogModes.NO);
/* End Process selected layers - from jazz-y */
if (theVisibility == false) {showOrHideLayer (true)};
if (isBackground == true) {selectAll ()};
flipHorizontally ();
if (isBackground == true) {deselect ()};
if (theVisibility == false) {showOrHideLayer (false)};
}
};
//////
function showOrHideLayer (theCheck) {
if (theCheck == false) {var idhide = stringIDToTypeID( "hide" )}
else {var idhide = stringIDToTypeID( "show" )};
try {
var desc22 = new ActionDescriptor();
var list2 = new ActionList();
var ref8 = new ActionReference();
ref8.putEnumerated( stringIDToTypeID( "layer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
list2.putReference( ref8 );
desc22.putList( stringIDToTypeID( "null" ), list2 );
executeAction( idhide, desc22, DialogModes.NO );
} catch (e) {}
};
////// 
function deselect () {
var desc5 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
desc5.putReference( stringIDToTypeID( "null" ), ref1 );
desc5.putEnumerated( stringIDToTypeID( "to" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "none" ) );
executeAction( stringIDToTypeID( "set" ), desc5, DialogModes.NO );
};
//////
function selectAll () {
var desc216 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
desc216.putReference( stringIDToTypeID( "null" ), ref1 );
desc216.putEnumerated( stringIDToTypeID( "to" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "allEnum" ) );
executeAction( stringIDToTypeID( "set" ), desc216, DialogModes.NO );
};
//////
function flipHorizontally () {
var desc6 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated( stringIDToTypeID( "layer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc6.putReference( stringIDToTypeID( "null" ), ref2 );
desc6.putUnitDouble( stringIDToTypeID( "width" ), stringIDToTypeID( "percentUnit" ), -100.000000 );
desc6.putBoolean( stringIDToTypeID( "linked" ), true );
executeAction( stringIDToTypeID( "transform" ), desc6, DialogModes.NO );
};
////// function to get the date //////
function timeString () {
var now = new Date();
return now.getTime()
};

 

Votes

Translate

Translate

Report

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
Engaged ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

quote

»Flip_only_selected_layers_horizontal.jsx« uses DOM-code for the flipping, using AM-code instead can speed this up. 

By @c.pfaffenbichler

And what about »Flip_only_selected_layers_verticaly.jsx« ? 

If I use ChatGPT to convert your code to vertically version, will its speed increase?

Votes

Translate

Translate

Report

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