• 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 remove everything except numbers from chart images?

Explorer ,
Feb 27, 2023 Feb 27, 2023

Copy link to clipboard

Copied

 

I receive about 500 to 1000 photos of charts or graphs on a daily basis that i have to remove all the components of the photos except their numerical values. 

 

This is an example of my photos: 

001.jpg 

I select graph bars using Magic Wand Tools in Photoshop

002.jpg 

Then move selected area to between logos and the numerical values

003.jpg 

And finally, by removing the various components of the images, only numerical values remain

004.jpg 

I have to do these steps with Photoshop action feature because the number of my daily photos is very high. 
I can do these steps with action feature automatically if the distance between the edge of the graph bars and the first digit of the numerical values is the same in all images. but the main problem here is that the space between the numerical values and the graph bars in the images received daily is not the same

 
For example, this is another photo where the distance between the numerical values and the bars of the graph is very close: 

005.jpg 

If I apply the steps I went through for the previous image using Photoshop action feature on this image, surely some of the numerical values will be removed in this image. 

 

How can I delete all the components of my daily images except the numerical values through the Photoshop action feature? 

Can I move selected area exactly to before the numeric values using the Photoshop script

 

Note: 

  1. I can't use Photoshop Color Range tool for selecting numeric values because numeric values have same color as the rest of the image contents. 
  2. My daily images have a single layer and are not smart objects
  3. number of images received daily is very high and I cannot do it manually. I must do it with Photoshop action feature or another automatic solution. 
  4. I can't use OCR tool because some of the images contain some logos that contain letters or numbers. If the logo numbers are extracted and combined with numerical values, it is not possible to find the extracted logo numbers. 
  5. The space between the graph bar and numerical values in each image is specific and this distance is different between different images. 
  6. The space between the graph bar and numerical values in a photo is the same. 
  7. All my images resolution is same 
  8. It is not a problem if resolution of the photo are changed. 
  9. I know that the explanation I provided is complicated, but I could not express my problem more simply than this. 

 

I have been facing this difficult problem for about three months and I hope I can find a solution here 

 

Sorry if there are any spelling errors in the text because my English is very poor. I wrote this text with the help of Google Translate.

TOPICS
Actions and scripting , Windows

Views

15.9K

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
Adobe
Community Expert ,
Mar 01, 2023 Mar 01, 2023

Copy link to clipboard

Copied

Please post several actual sample images that you have not edited yet. 

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
LEGEND ,
Mar 01, 2023 Mar 01, 2023

Copy link to clipboard

Copied

This may not be possible at all with image editing, at least not at the level we work on. You need to get this data in some other format than as 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 ,
Mar 01, 2023 Mar 01, 2023

Copy link to clipboard

Copied

This part is a problem. 

Untitled-1.jpg

In the other image the separate blocks extend up to the left edge, did you add that vertical rectangle or is part of the original image? 

 

Edit: For the one image automation can work out, but it is impossible to say if the actual images truly fit this appearance. 

As the bars are separate on the left side it is possible to intersect the overal selection with rectangular Selections that fot the height of those bars, Make Work Path and drop the first subPathItem. 

Screenshot 2023-03-01 at 17.47.13.pngScreenshot 2023-03-01 at 17.47.33.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
Explorer ,
Mar 01, 2023 Mar 01, 2023

Copy link to clipboard

Copied

I added that vertical rectangle and it is not part of the original images. It is not present in any of the received daily photos. I would add that vertical rectangle so that I can select all the blocks with the magic wand tool in action feature. All my photos are like the one on the right. 

 

several actual sample images: 

Untitled001.jpg 

 

 

Untitled002.jpg 

 

 

Untitled003.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 ,
Mar 01, 2023 Mar 01, 2023

Copy link to clipboard

Copied

With the four meaningful test images I get these results, I set them to 72ppi, though: 

Screenshot 2023-03-02 at 08.21.31.png

// cover up the two leftmost elements in lines in gray rgb image;
// 2023, use it at your own risk;
if (app.documents.length > 0) {
    var myDocument = activeDocument;
// set to pixels;
    var originalRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.POINTS;
    myDocument.resizeImage (undefined, undefined, 72, ResampleMethod.NONE);
    app.togglePalettes();
// determine number of lines;
    loadChannelAsSelection("red",true);
    intersectSelectionRectangle ([0,0,20,myDocument.height], true);
    makeWorkPath (0.5);
    var theLinesPath = collectPathInfoFromDesc2012 (myDocument, myDocument.pathItems[myDocument.pathItems.length-1]);
// work on the non-bars;
    var numbersPath = new Array;
    loadChannelAsSelection("red", true);
    expandSelection(3);
    myDocument.quickMaskMode = true;
    hideRGBChannels ();
    intersectSelectionRectangle ([0,0,20,myDocument.height], false);
    growSelection ();
    expandSelection(2);
    fillWithBlack ("black");
    useMagicWand2022 ([1,1]);
    myDocument.selection.invert();
    fillWithBlack ("white");
// create intersections and create paths;
    for (var m = 0; m < theLinesPath.length; m++) {
        myDocument.selection.deselect();
        loadCurrentChannelAsSelection();
        intersectSelectionRectangle ([0,theLinesPath[m][0][0][1],myDocument.width,theLinesPath[m][theLinesPath[m][0].length-2][0][1]], true);
        makeWorkPath (0.5);
        var thePath = collectPathInfoFromDesc2012 (myDocument, myDocument.pathItems[myDocument.pathItems.length-1]);
        thePath.sort(sortArrayByIndexedItem);
        for (var n = 1; n < thePath.length; n++) {
            numbersPath.push(thePath[n])
        }
    };
myDocument.quickMaskMode = false;
var theNewPath = createPath2022(numbersPath, "numbers");
selectionFromPath (myDocument.pathItems[myDocument.pathItems.length-1], true);
myDocument.selection.invert();
createSolidColorLayer(255,255,255);
// reset;
app.preferences.rulerUnits = originalRulerUnits;
app.togglePalettes();
};
////////////////////////////////////
////// collect path info from actiondescriptor, smooth added //////
function collectPathInfoFromDesc2012 (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();
    for (var l = 0; l < myDocument.pathItems.length; l++) {
        var thisPath = myDocument.pathItems[l];
        if (thisPath == thePath && thisPath.kind == PathKind.WORKPATH) {
            ref.putProperty(idPath, cTID("WrPt"));
            };
        if (thisPath == thePath && thisPath.kind != PathKind.WORKPATH && thisPath.kind != PathKind.VECTORMASK) {
            ref.putIndex(idPath, l + 1);
            };
        if (thisPath == thePath && thisPath.kind == PathKind.VECTORMASK) {
            var idvectorMask = stringIDToTypeID( "vectorMask" );
            ref.putEnumerated( idPath, idPath, idvectorMask );
            };
        };
    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;
    };
////// make work path from selection //////
function makeWorkPath (theTolerance) {
    // =======================================================
    var idMk = charIDToTypeID( "Mk  " );
        var desc5 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref3 = new ActionReference();
            var idPath = charIDToTypeID( "Path" );
            ref3.putClass( idPath );
        desc5.putReference( idnull, ref3 );
        var idFrom = charIDToTypeID( "From" );
            var ref4 = new ActionReference();
            var idcsel = charIDToTypeID( "csel" );
            var idfsel = charIDToTypeID( "fsel" );
            ref4.putProperty( idcsel, idfsel );
        desc5.putReference( idFrom, ref4 );
        var idTlrn = charIDToTypeID( "Tlrn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc5.putUnitDouble( idTlrn, idPxl, theTolerance );
    executeAction( idMk, desc5, DialogModes.NO );
    };
////// load layer mask //////
function loadChannelAsSelection(theName, theInvert) {  
    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( stringIDToTypeID( "set" ), desc70, DialogModes.NO );
    } catch (_error) {alert (_error)}
    };
////// intersect selection //////
function intersectSelectionRectangle (theArray, theIntersect) {
    if (theIntersect == false ||  theIntersect == undefined) {var idinterfaceWhite = charIDToTypeID( "setd" )}
    else {var idinterfaceWhite = stringIDToTypeID( "interfaceWhite" )};
//var idinterfaceWhite = stringIDToTypeID( "interfaceWhite" );
var desc5 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
    desc5.putReference( stringIDToTypeID( "null" ), ref1 );
    var desc6 = new ActionDescriptor();
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc6.putUnitDouble( stringIDToTypeID( "top" ), idpixelsUnit, theArray[1] );
    desc6.putUnitDouble( stringIDToTypeID( "left" ), idpixelsUnit, theArray[0] );
    desc6.putUnitDouble( stringIDToTypeID( "bottom" ), idpixelsUnit, theArray[3] );
    desc6.putUnitDouble( stringIDToTypeID( "right" ), idpixelsUnit, theArray[2] );
desc5.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "rectangle" ), desc6 );
executeAction( idinterfaceWhite, desc5, 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 );
};
////// grow selection //////
function growSelection () {
var desc11 = new ActionDescriptor();
    var ref2 = new ActionReference();
    ref2.putProperty( stringIDToTypeID( "channel" ), stringIDToTypeID( "selection" ) );
desc11.putReference( stringIDToTypeID( "null" ), ref2 );
desc11.putInteger( stringIDToTypeID( "tolerance" ), 30 );
desc11.putBoolean( stringIDToTypeID( "antiAlias" ), true );
executeAction( stringIDToTypeID( "grow" ), desc11, DialogModes.NO );
};
////// hide rgb channels //////
function hideRGBChannels () {
var idchannel = stringIDToTypeID( "channel" );
var desc15 = new ActionDescriptor();
    var list1 = new ActionList();
        var ref3 = new ActionReference();
        ref3.putEnumerated( idchannel, idchannel, stringIDToTypeID( "red" ) );
    list1.putReference( ref3 );
        var ref4 = new ActionReference();
        ref4.putEnumerated( idchannel, idchannel, stringIDToTypeID( "grain" ) );
    list1.putReference( ref4 );
        var ref5 = new ActionReference();
        ref5.putEnumerated( idchannel, idchannel, stringIDToTypeID( "blue" ) );
    list1.putReference( ref5 );
desc15.putList( stringIDToTypeID( "null" ), list1 );
executeAction( stringIDToTypeID( "hide" ), desc15, 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) {}
};
////// 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 );
	};
////// create a path from collectPathInfoFromDesc2012-array //////
function createPath2022(theArray, thePathsName) {
    var originalRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    // thanks to xbytor;
    cTID = function(s) { return app.charIDToTypeID(s); };
    sTID = function(s) { return app.stringIDToTypeID(s); };
    
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putProperty(cTID('Path'), cTID('WrPt'));
        desc1.putReference(sTID('null'), ref1);
        var list1 = new ActionList();
        
    for (var m = 0; m < theArray.length; m++) {
        var thisSubPath = theArray[m];
        
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(sTID('shapeOperation'), sTID('shapeOperation'), thisSubPath[thisSubPath.length - 1]);
        var list2 = new ActionList();
        var desc3 = new ActionDescriptor();
        desc3.putBoolean(cTID('Clsp'), thisSubPath[thisSubPath.length - 2]);
        var list3 = new ActionList();
        
    for (var n = 0; n < thisSubPath.length - 2; n++) {
        var thisPoint = thisSubPath[n];
        
        var desc4 = new ActionDescriptor();
        var desc5 = new ActionDescriptor();
        desc5.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[0][0]);
        desc5.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[0][1]);
        desc4.putObject(cTID('Anch'), cTID('Pnt '), desc5);
        var desc6 = new ActionDescriptor();
        desc6.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[1][0]);
        desc6.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[1][1]);
        desc4.putObject(cTID('Fwd '), cTID('Pnt '), desc6);
        var desc7 = new ActionDescriptor();
        desc7.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[2][0]);
        desc7.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[2][1]);
        desc4.putObject(cTID('Bwd '), cTID('Pnt '), desc7);
        desc4.putBoolean(cTID('Smoo'), thisPoint[3]);
        list3.putObject(cTID('Pthp'), desc4);
        
        };
        
        desc3.putList(cTID('Pts '), list3);
        list2.putObject(cTID('Sbpl'), desc3);
        desc2.putList(cTID('SbpL'), list2);
        list1.putObject(cTID('PaCm'), desc2);
        };
        
        desc1.putList(cTID('T   '), list1);
        executeAction(cTID('setd'), desc1, DialogModes.NO);
    
    // name work path;
    var desc30 = new ActionDescriptor();
    var ref6 = new ActionReference();
    var idPath = charIDToTypeID( "Path" );
    ref6.putClass( idPath );
    desc30.putReference( charIDToTypeID( "null" ), ref6 );
    var ref7 = new ActionReference();
    ref7.putProperty( idPath, charIDToTypeID( "WrPt" ) );
    desc30.putReference( charIDToTypeID( "From" ), ref7 );
    desc30.putString( charIDToTypeID( "Nm  " ), thePathsName );
    executeAction( charIDToTypeID( "Mk  " ), desc30, DialogModes.NO );
    /// get index;
    var ref = new ActionReference();
    ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("itemIndex"));
    ref.putEnumerated( charIDToTypeID("Path"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var pathDesc = executeActionGet(ref);
    app.preferences.rulerUnits = originalRulerUnits;
    return pathDesc.getInteger(stringIDToTypeID("itemIndex"))
    };
////// channel as selection //////
function loadCurrentChannelAsSelection () {
var idset = stringIDToTypeID( "set" );
    var desc25 = new ActionDescriptor();
    var idnull = stringIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idchannel = stringIDToTypeID( "channel" );
        var idselection = stringIDToTypeID( "selection" );
        ref6.putProperty( idchannel, idselection );
    desc25.putReference( idnull, ref6 );
    var idto = stringIDToTypeID( "to" );
        var ref7 = new ActionReference();
        var idchannel = stringIDToTypeID( "channel" );
        var idordinal = stringIDToTypeID( "ordinal" );
        var idtargetEnum = stringIDToTypeID( "targetEnum" );
        ref7.putEnumerated( idchannel, idordinal, idtargetEnum );
    desc25.putReference( idto, ref7 );
executeAction( idset, desc25, DialogModes.NO );
};
////// function to make selection from path //////
function selectionFromPath (thePath, antiAliasing) {
    thePath.select();
    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 idPath = charIDToTypeID( "Path" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref3.putEnumerated( idPath, idOrdn, idTrgt );
        desc3.putReference( idT, ref3 );
        var idAntA = charIDToTypeID( "AntA" );
        desc3.putBoolean( idAntA, antiAliasing );
        var idFthr = charIDToTypeID( "Fthr" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc3.putUnitDouble( idFthr, idPxl, 0.000000 );
    executeAction( idsetd, desc3, DialogModes.NO );
    thePath.deselect();
};    
////// make solid color layer //////
function createSolidColorLayer (theRed, theGreen, theBlue) {
    var desc8 = new ActionDescriptor();
        var ref6 = new ActionReference();
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        ref6.putClass( idcontentLayer );
    desc8.putReference( charIDToTypeID( "null" ), ref6 );
        var desc9 = new ActionDescriptor();
            var desc10 = new ActionDescriptor();
                var desc11 = new ActionDescriptor();
                desc11.putDouble( charIDToTypeID( "Rd  " ), theRed );
                desc11.putDouble( charIDToTypeID( "Grn " ), theGreen );
                desc11.putDouble( charIDToTypeID( "Bl  " ), theBlue );
            var idRGBC = charIDToTypeID( "RGBC" );
            desc10.putObject( charIDToTypeID( "Clr " ), idRGBC, desc11 );
        desc9.putObject( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ), desc10 );
    desc8.putObject( charIDToTypeID( "Usng" ), idcontentLayer, desc9 );
    executeAction( charIDToTypeID( "Mk  " ), desc8, DialogModes.NO );
    return activeDocument.activeLayer
    };
////// sort a double array, thanks to sam, http://www.rhinocerus.net/forum/lang-javascript/ //////
function sortArrayByIndexedItem(a,b) {
    //var theIndex = 1;
    if (a[0][0][0]<b[0][0][0]) return -1;
    if (a[0][0][0]>b[0][0][0]) return 1;
    return 0;
    };

 

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
Explorer ,
Mar 01, 2023 Mar 01, 2023

Copy link to clipboard

Copied

I tested your script on this sample photo: 
tesssst4545.jpg 

and result: 

tesssst4545_result.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 ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied


@abolfazl28627254vbil wrote:

I tested your script on this sample photo: 
tesssst4545.jpg 

and result: 


Well, I guess that’s what happens when you provide test files that differ considerably from the files you actually work with. 

 

You can try using a lower expansion in line 18. 

 

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
Explorer ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

ok i changed line 18 and script worked for that image but this time i test script on this sample image: 
errr1.jpg 

and i get this error: 

errr2.jpg 

even i changed line 18 to lower or higher value but it had no effect on the error

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 ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

You provide unrepresentative sample files you get problems on the actual files. 

 

Try changing the value »20« to »10« in lines 12 and 21. 

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
Explorer ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

quote

You provide unrepresentative sample files you get problems on the actual files. 

 

Try changing the value »20« to »10« in lines 12 and 21. 


By @c.pfaffenbichler

ok, i changed that vlaues and worked for 2nd sample image but again i tried script on this new sample image: 
rrrrrtt44444.jpg 

and this time i get this error: 

errrr44.jpg 

If I try to run the script for 500 or 1000 charts with different number of bars, I will probably get multiple errors!

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 ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

I provided a Script that worked for the sample images; maybe you need to start doing your own trouble-shooting? 

 

I guess the easiest solution would be wrapping the operation in a try-clause – that way the files that don’t yield the intended results would not be processed but at least they should not stop the process for the other files. 

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
Explorer ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

quote

I provided a Script that worked for the sample images; maybe you need to start doing your own trouble-shooting? 

 

I guess the easiest solution would be wrapping the operation in a try-clause – that way the files that don’t yield the intended results would not be processed but at least they should not stop the process for the other files. 


By @c.pfaffenbichler

You wrote a very good script. Thank you very much, but your script has errors. in a few hours, I tested your script with about 50 photos, and even in some cases, some logos are not deleted. 

I don't know how can i create try-clause in photoshop. if possible, please tell me to create try-clause and test script on 500 or 1000 sample images and post here errors. 

Because the number of received photos is high, I cannot use the script that does the job 90% 

Because checking 500 or 1000 photos to find and edit errors is very difficult and time-consuming 

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 ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied


I tested your script with about 50 photos, and even in some cases, some logos are not deleted. 

Interesting; what sets those logos (or other properties) in those images apart from those in the others? 

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
Explorer ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

quote

I tested your script with about 50 photos, and even in some cases, some logos are not deleted. 

Interesting; what sets those logos (or other properties) in those images apart from those in the others? 


By @c.pfaffenbichler

for example this is one of the images with the logos incompletely removed: 

tertertertert.jpg 

first logo not removed: 

errrrrr.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 ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied


@abolfazl28627254vbil wrote:
quote

I tested your script with about 50 photos, and even in some cases, some logos are not deleted. 

Interesting; what sets those logos (or other properties) in those images apart from those in the others? 


By @c.pfaffenbichler

for example this is one of the images with the logos incompletely removed: 

tertertertert.jpg 

first logo not removed: 

errrrrr.jpg


It seems the Script did exactly what it was intended to do: It covered the left bars (that define the lines) and the next »object« right of that (the »A« of the logo).

 

»logo« and »numbers« are essentially meaningless terms here. 

To Photoshop they are practically just pixels* and if the logo consists of severeal distinct parts of similar size as the numbers AND is as close to the first number as the numbers are to each other how do you expect the distinction to be made? 

If the distance between logos and numbers vary so much automation seems even more difficult. 

 

The one distinguishing feature in this case could be height; so it might be possible to evaluate the subPathItems for topmost and lowermost PathPoint and try to make the distinction that way, but if another logo turns up that consists of distinct letters of comparable height that would be useless again. 

 

*: The »Match Font«-feature seems to employ some kind of OCR but that does not appear to be any help here. 

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
LEGEND ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

I think one thing needs to be noted. These forums are not a "scripter for free" place. We are here to help you, not do all of the work, especially if it involves writing a complicated and specialized script.

The backstory here doesn't make much sense, you employer has given you a job which can't be done with Photoshop out-of-the-box, and you are expected to come to a help forum and have volunteers create a custom solution for free or you will lose your job?

My suggestion is to download Microsoft VSCode (the current developer tool for writing scripts, its free) and the Photoshop SDK and start working on this yourself. Or, your employer can hire someone to take the code we have supplied and finish it to production standards. Or maybe you can tell your boss that the data needs to be supplied in a different manner. Or use a different tool, like OCR and Excel.

I'm not trying to be mean or critical of you, I appreciate that you may be in a tough position with an unreasonable job to do. But at some point, you need to do this job yourself and not just demand that the people here do it for you.

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
Explorer ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

quote

I think one thing needs to be noted. These forums are not a "scripter for free" place. We are here to help you, not do all of the work, especially if it involves writing a complicated and specialized script.

The backstory here doesn't make much sense, you employer has given you a job which can't be done with Photoshop out-of-the-box, and you are expected to come to a help forum and have volunteers create a custom solution for free or you will lose your job?

My suggestion is to download Microsoft VSCode (the current developer tool for writing scripts, its free) and the Photoshop SDK and start working on this yourself. Or, your employer can hire someone to take the code we have supplied and finish it to production standards. Or maybe you can tell your boss that the data needs to be supplied in a different manner. Or use a different tool, like OCR and Excel.

I'm not trying to be mean or critical of you, I appreciate that you may be in a tough position with an unreasonable job to do. But at some point, you need to do this job yourself and not just demand that the people here do it for you.


By @Lumigraphics

I can use OCR tool but the problem is that some logos have letters or numbers and OCR tool extracts letters and numbers in the logos in addition to the numerical values. After OCR and extracting anything from photos, it is difficult to separate numerical values from letters and numbers in logos that extracted. If I can increase the space between bar and logo and numerical values and put a special symbol in space between them that OCR tool can extract, I can extract with anything with OCR and after extract i can seprate numerical values using special symbol that added in space between. Today I asked from company and I was allowed to use OCR tool, but the problem I explained is standing in using OCR.

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
LEGEND ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

I think you missed my point. We are here to help if you are stuck, to get you working again. Its really difficult and time-consuming and unrealistic for people here to make an entire custom solution for you. Maybe look at this as a chance to learn something about writing JavaScript.

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
Explorer ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

What I asked in this thread is the features that Adobe should add to Photoshop! 

1) Separate selected components of a photo into different layers 

2) Sorting layers of a photo - from left to right or right to left - up to down or down to up 

3) Split a photo by specific color into different layers 

4) Increase the distance between different photo components based on color without stretching or changing the components 

5) Photoshop selects based on color (color range), but does not select based on height, length, and width! 

And many other simple features that Photoshop does not yet have and should add. 

So, despite what you said, my company should hire a JavaScript programmer instead of a Photoshop employee! 

What I requested in this topic could be done with the features available in Photoshop. But up to 95%. (You can see the initial answers about using smart filters that were replied on my post in this thread) 

What guarantee is there if I spend money to write a script and the next day Photoshop does not add the capabilities of that script to Photoshop? Someone who learns Photoshop wants to do graphic work, not scripting and coding work. My preference is to do the work I requested in this thread with the ability of action and graphic work than to learn JavaScript! 

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 ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied


@abolfazl28627254vbil wrote:

What I asked in this thread is the features that Adobe should add to Photoshop! 


You are free to post a Feature Request. 

But Photohsop is image editing software, and your very specific needs (that seem essentially unrelated to the editing of photos) would hardly seem to matter to most of the Photoshop user base. 

 

Have you done research on whether there might be other software that might fit your needs better? 

 


So, despite what you said, my company should hire a JavaScript programmer instead of a Photoshop employee!

What do you mean by »Photoshop employee«? 

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
Explorer ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

quote
quote

What I asked in this thread is the features that Adobe should add to Photoshop! 


By @abolfazl28627254vbil

You are free to post a Feature Request. 

But Photohsop is image editing software, and your very specific needs (that seem essentially unrelated to the editing of photos) would hardly seem to matter to most of the Photoshop user base. 

 

Have you done research on whether there might be other software that might fit your needs better? 

 


So, despite what you said, my company should hire a JavaScript programmer instead of a Photoshop employee!

What do you mean by »Photoshop employee«? 


By @c.pfaffenbichler

No - I didn't research because the problem I have is a special problem and I don't know what I should search about!

If you know another photo editing software that can do this, please introduce it. Of course, a software that has a feature like Photoshop action feature and can edit photos collectively

A software that has better feature than Photoshop and can keep only parts of numerical values in my photos

Please, if you introduce another software, also mention the capabilities of that software that can help me

I can't use OCR tools either for the reasons I mentioned earlier

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

Copy link to clipboard

Copied

No - I didn't research because the problem I have is a special problem and I don't know what I should search about!

If you know another photo editing software that can do this, please introduce it. Of course, a software that has a feature like Photoshop action feature and can edit photos collectively

A software that has better feature than Photoshop and can keep only parts of numerical values in my photos

Please, if you introduce another software, also mention the capabilities of that software that can help me

I can't use OCR tools either for the reasons I mentioned earlier


I don’t understand your reasoning in the statement

»I can't use OCR tool because some of the images contain some logos that contain letters or numbers. If the logo numbers are extracted and combined with numerical values, it is not possible to find the extracted logo numbers.«

If you manage to get text out of the images separating letters and numbers should be easy with RegExp. 

 

I don’t know which programs would be a better fit, but I suspect you should not fixate in image editors – because I doubt any of those are designed to do what you want. 

I think there are applications that are used to scan bills for bookkeeping and those might do a decent job at extracting text/numbers – not sure if they would be useful to you. 

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
Explorer ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

quote
No - I didn't research because the problem I have is a special problem and I don't know what I should search about!

If you know another photo editing software that can do this, please introduce it. Of course, a software that has a feature like Photoshop action feature and can edit photos collectively

A software that has better feature than Photoshop and can keep only parts of numerical values in my photos

Please, if you introduce another software, also mention the capabilities of that software that can help me

I can't use OCR tools either for the reasons I mentioned earlier


I don’t understand your reasoning in the statement

»I can't use OCR tool because some of the images contain some logos that contain letters or numbers. If the logo numbers are extracted and combined with numerical values, it is not possible to find the extracted logo numbers.«

If you manage to get text out of the images separating letters and numbers should be easy with RegExp. 

 

I don’t know which programs would be a better fit, but I suspect you should not fixate in image editors – because I doubt any of those are designed to do what you want. 

I think there are applications that are used to scan bills for bookkeeping and those might do a decent job at extracting text/numbers – not sure if they would be useful to you. 


By @c.pfaffenbichler

Use OCR tool like google lens for this sample image to see what I mean: 

Untitled.jpg 

You will surely get such extracted text: 

 

3 499697076
2 421161475
4 324524779
7221195909

 

You can see that the number in the last logo has been merged with the numerical value! 

Suppose I come across 1000 photos with logos similar to the logos in this photo and I have extracted the numerical values in the photos with OCR tool, How can I find out which of the thousands of extracted values is merged with a logo number? 

 

I can only use OCR tool if it is placed between the logos and the numerical values of the scannable symbols: 

Untitled22.jpg 

Or any other better way so that the numerical values are not merged with the numbers in the logos. 

I hope with this example you have fully understood why I can't use OCR tool

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
Explorer ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

Use OCR tool for this sample image to understand what I mean: 

Untitled.jpg 

You will certainly encounter such a result: 

 

3 499697076
2 421161475
4 324524779
7221195909

 

You can see that the last numerical value is merged with the number in the last logo! 

Even if your OCR tool can extract numerical values without error and integration, there will be errors among thousands of photos. I can't go through a thousand photos with the extracted text result one by one. 

 

I can use OCR tool only in one case. There should be scannable icons among the numerical values and logos: 

Untitled22.jpg 

Or any better way to prevent merging of numeric values and numbers in logos during OCR 

I hope you can fully understand my limitations in using OCR tool with this example

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
LEGEND ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

We are not responsible for creating a custom solution in Photoshop for this narrow use case. Again, that is not what these forums are for, they are here if you have a question or problem and need help. You are certainly free to learn JavaScript coding and work on this yourself but you can't just expect us to come up with a solution. This is far from a normal image editng task.

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