Skip to main content
Inspiring
July 31, 2021
Answered

How to cut out photos [PIRATED SOFTWARE — LOCKED BY MODERATOR]

  • July 31, 2021
  • 5 replies
  • 20013 views

Hi,

 

I have more than a hundred old black and white photos that was scanned in jpg. They have all an white border that I want to cut out. Is there a way to computerize these photos in batch with Photoshop CC (2017 version on Windows 10) to cut out their border, which are all different widths. You can see two examples I have included here.

 

Thank you!

This topic has been closed for replies.
Correct answer davescm

Hi Nancy,

 

I saw also on their wehsite than it's a subscription plan today to get Photoshop 2017 CC. I am surprise. I remember than I bought Photoshop CC 2014 (v15) in March 2020 from them. It was a one-time paid version. I thought that it was possible to buy Adobe softwares from reseller. Moreover, I bought other softwares from them in the past always with credit card with no problem. They have good prices and an excellent service.

 

At one point, I got some problems with Ps 2014 CC. Remotely, the technical support service of this website could not fix the problem. So, they updated free to Photoshop CC 2017 (v18). If it was an illegal software, I did not know. I don't want to get in troubles.


Let us be clear :

CS versions were sold with perpetual licenses. The last CS version was CS6

 

CC versions are all subscription only. Be that CC, CC 2014, 2015 .....etc ALL CC versions are subscription only and the subscription gives you access to the current versions. If you are using a "perpetual version" of CC then it is a hacked, pirated copy and as such illegal.

 

Dave

5 replies

Legend
August 3, 2021

Who wants, can play with CropAndStraighten.

Faster than motionBlur.

Original images can be tilted.

 

crop(true);
crop();

function crop(select_only)
    {
    try {
        var d = executeAction(stringIDToTypeID("CropPhotos0001"), undefined, DialogModes.NO);
        var l = d.getList(stringIDToTypeID("value"));
        var p = new Array();
        for (var i = 0; i < 8; i+=2) p.push([l.getDouble(i), l.getDouble(i+1)]);

        if (select_only) { activeDocument.selection.select(p); return; }

        var d = new ActionDescriptor();
        var d1 = new ActionDescriptor();
        var d2 = new ActionDescriptor();
        d2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
        d2.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"),   0);
        d1.putObject(stringIDToTypeID("center"), stringIDToTypeID("point"), d2);

        for (var i = 0; i < 4; i++)
            {
            var d3 = new ActionDescriptor();
            d3.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), p[i][0]);
            d3.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"),   p[i][1]);
            d1.putObject(stringIDToTypeID("quadCorner"+i), stringIDToTypeID("offset"), d3);
            }

        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("quadrilateral"), d1);
        executeAction(stringIDToTypeID("perspectiveCrop"), d, DialogModes.NO);

        return true;
        }
    catch (e) { alert(e); throw(e); }
    }

 

Kukurykus
Legend
August 3, 2021

Loll about month ago I wanted to ask you how to use 'CropPhotosAuto0001' to avoid duplication of cropped layer to new documents. In the end I used other method, but now I see I should ask. So easy 😉

Legend
August 2, 2021

You can try using this script. Essentially the same as the action I suggested above, but it itself ignores out-of-frame garbage and, in theory, no additional photo processing is required. However, it still does not take into account the possible rotation of the photo

 

#target photoshop

var lr = new AM('layer'),
    doc = new AM('document');

lr.copyToLayer(2)
lr.motionBlur(90, 2000)
lr.threshold(230)
var layerBounds = lr.descToObject(lr.getProperty('bounds')),
    objectBounds = {};
lr.selectOrdinalChannel()
lr.substractSelection(layerBounds.top, layerBounds.right / 2, layerBounds.bottom, layerBounds.right)
objectBounds.left = doc.hasProperty('selection') ? lr.descToObject(doc.getProperty('selection')).right : layerBounds.left

lr.selectOrdinalChannel()
lr.substractSelection(layerBounds.top, layerBounds.left, layerBounds.bottom, layerBounds.right / 2)
objectBounds.right = doc.hasProperty('selection') ?  lr.descToObject(doc.getProperty('selection')).left : layerBounds.right

lr.deselect()
lr.deleteOrdinalLayer()

lr.motionBlur(0, 2000)
lr.threshold(230)

lr.selectOrdinalChannel()
lr.substractSelection(layerBounds.bottom / 2, layerBounds.left, layerBounds.bottom, layerBounds.right)
objectBounds.top = doc.hasProperty('selection') ? lr.descToObject(doc.getProperty('selection')).bottom : layerBounds.top

lr.selectOrdinalChannel()
lr.substractSelection(layerBounds.top, layerBounds.left, layerBounds.bottom / 2, layerBounds.right)
objectBounds.bottom = doc.hasProperty('selection') ? lr.descToObject(doc.getProperty('selection')).top : layerBounds.bottom
lr.deleteOrdinalLayer()

lr.makeSelection(objectBounds)
lr.crop()
lr.deselect()

function AM(target, order) {
    var s2t = stringIDToTypeID,
        t2s = typeIDToStringID;

    target = s2t(target)

    this.getProperty = function (property, descMode, id, idxMode) {
        property = s2t(property);
        (r = new ActionReference()).putProperty(s2t('property'), property);
        id != undefined ? (idxMode ? r.putIndex(target, id) : r.putIdentifier(target, id)) :
            r.putEnumerated(target, s2t('ordinal'), order ? s2t(order) : s2t('targetEnum'));
        return descMode ? executeActionGet(r) : getDescValue(executeActionGet(r), property)
    }

    this.hasProperty = function (property, id, idxMode) {
        property = s2t(property);
        (r = new ActionReference()).putProperty(s2t('property'), property);
        id ? (idxMode ? r.putIndex(target, id) : r.putIdentifier(target, id))
            : r.putEnumerated(target, s2t('ordinal'), order ? s2t(order) : s2t('targetEnum'));
        return executeActionGet(r).hasKey(property)
    }

    this.descToObject = function (d) {
        var o = {}
        for (var i = 0; i < d.count; i++) {
            var k = d.getKey(i)
            o[t2s(k)] = getDescValue(d, k)
        }
        return o
    }

    this.copyToLayer = function (copies) {
        var i = copies ? copies : 1
        for (i = 0; i < copies; i++) executeAction(s2t('copyToLayer'), undefined, DialogModes.NO);
    }

    this.motionBlur = function (angle, distance) {
        (d = new ActionDescriptor()).putInteger(s2t('angle'), angle);
        d.putUnitDouble(s2t('distance'), s2t('pixelsUnit'), distance);
        executeAction(s2t('motionBlur'), d, DialogModes.NO);
    }

    this.deselect = function () {
        (r = new ActionReference()).putProperty(s2t('channel'), s2t('selection'));
        (d = new ActionDescriptor()).putReference(s2t('null'), r);
        d.putEnumerated(s2t('to'), s2t('ordinal'), s2t('none'));
        executeAction(s2t('set'), d, DialogModes.NO);
    }

    this.threshold = function (level) {
        (d = new ActionDescriptor()).putInteger(s2t('level'), level);
        executeAction(s2t('thresholdClassEvent'), d, DialogModes.NO);
    }

    this.selectOrdinalChannel = function () {
        (r = new ActionReference()).putProperty(s2t('channel'), s2t('selection'));
        (d = new ActionDescriptor()).putReference(s2t('null'), r);
        (r1 = new ActionReference()).putEnumerated(s2t('channel'), s2t('ordinal'), s2t('targetEnum'));
        d.putReference(s2t('to'), r1);
        executeAction(s2t('set'), d, DialogModes.NO);
    }

    this.substractSelection = function (top, left, bottom, right) {
        (d1 = new ActionDescriptor()).putUnitDouble(s2t('top'), s2t('pixelsUnit'), top);
        d1.putUnitDouble(s2t('left'), s2t('pixelsUnit'), left);
        d1.putUnitDouble(s2t('bottom'), s2t('pixelsUnit'), bottom);
        d1.putUnitDouble(s2t('right'), s2t('pixelsUnit'), right);
        d.putObject(s2t('to'), s2t('rectangle'), d1);
        executeAction(s2t('subtractFrom'), d, DialogModes.NO);
    }

    this.makeSelection = function (bounds) {
        (r = new ActionReference()).putProperty(s2t('channel'), s2t('selection'));
        (d = new ActionDescriptor()).putReference(s2t('null'), r);
        (d1 = new ActionDescriptor()).putUnitDouble(s2t('top'), s2t('pixelsUnit'), bounds.top);
        d1.putUnitDouble(s2t('left'), s2t('pixelsUnit'), bounds.left);
        d1.putUnitDouble(s2t('bottom'), s2t('pixelsUnit'), bounds.bottom);
        d1.putUnitDouble(s2t('right'), s2t('pixelsUnit'), bounds.right);
        d.putObject(s2t('to'), s2t('rectangle'), d1);
        executeAction(s2t('set'), d, DialogModes.NO);
    }

    this.deleteOrdinalLayer = function () {
        (r = new ActionReference()).putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
        (d = new ActionDescriptor()).putReference(s2t('null'), r);
        executeAction(s2t('delete'), d, DialogModes.NO);
    }

    this.crop = function () {
        (d = new ActionDescriptor()).putBoolean(s2t('delete'), true);
        executeAction(s2t('crop'), d, DialogModes.NO);
    }

    function getDescValue(d, p) {
        switch (d.getType(p)) {
            case DescValueType.OBJECTTYPE: return (d.getObjectValue(p));
            case DescValueType.LISTTYPE: return d.getList(p);
            case DescValueType.REFERENCETYPE: return d.getReference(p);
            case DescValueType.BOOLEANTYPE: return d.getBoolean(p);
            case DescValueType.STRINGTYPE: return d.getString(p);
            case DescValueType.INTEGERTYPE: return d.getInteger(p);
            case DescValueType.LARGEINTEGERTYPE: return d.getLargeInteger(p);
            case DescValueType.DOUBLETYPE: return d.getDouble(p);
            case DescValueType.ALIASTYPE: return d.getPath(p);
            case DescValueType.CLASSTYPE: return d.getClass(p);
            case DescValueType.UNITDOUBLE: return (d.getUnitDoubleValue(p));
            case DescValueType.ENUMERATEDTYPE: return [t2s(d.getEnumerationType(p)), t2s(d.getEnumerationValue(p))];
            default: break;
        };
    }
}

 

 

Inspiring
August 2, 2021

Hi jazz-y,

 

Since I am a novice with Photoshop, but happy to learn it, your solution seems promising to me. But for me, it's high flying. I don't know how to use it. Can you help me with that?

Inspiring
August 4, 2021

Loll it seems you completely don't understand me 🙂

 

I mean if you have Photoshop subscription you do not have to pay any extra money to get latest release. So if you have now 2017 version, you can easily upgrade it to 2021 with no cost.


I don't have Photoshop subscription. I bought my Ps CC 2017 on the internet site of Software Deal. And like r-bin wrote, sometimes it's a problem related to the obsolescence of the operating system or the hardware. Me, I have Windows 10, but I bought my laptop in 2014. The hardware doesn't meet all requirements to run Ps CC 2017, but in crossing my fingers, it works. 🙂

Legend
August 2, 2021

Trim automation requires uniform fill around the edges of the frame - this is difficult to achieve on scanned images.

 

If all images are relatively even, then motion blur can be used to define the boundaries of the image. Blur in one direction, blur in the other, overlay layers to get a mask. For example like this:

The only drawback is that the dark edges of the photos caught in the frame interfere. They either need to be overwritten manually, or you need to select cropping (or fill) parameters to remove them during batch processing.

 

In principle, this problem can be solved using a script (sequentially create a selection on each side of the frame, ignoring all coordinates except the inner part). But there will remain a problem with frames that were located with rotation (you cannot process them with blur).

I do not pretend to be a perfect solution, but maybe it will help.

Kukurykus
Legend
August 2, 2021

How do you 'set selection to current channel with inverse'?

Legend
August 2, 2021

🙂 bad screenshot. these are 2 different steps - creating a selection and inverting it

Trevor.Dennis
Community Expert
Community Expert
July 31, 2021

This will work on some of the images, but not all of them.  Your second example, for instance, has darker tones in the top right corner which will stop this from working.  It might save you some time time though.

 

Open one of the images and start a new Action.  For argument sake, call it 'Remove Border'.

Record the following steps and stop the Action.

 

1) Add a Levels adjustment layer with theses values

2) Image Trim > top left corner

3) Delete the Levels Adjustment layer

Stop the Action.

 

COPY all of the images to a new folder.

Go File > Image Processor

Select the folder with the copied images

Decide where to save the processed images, or use the same location (only because you are using copies)

Decide on a format to save the processed images and the quality (if JPG)

Check Run Action and chose the action you made (Remove Border)

Run the action. Job done

 

Inspiring
August 1, 2021

Thank you for your answers Geppetto Luis and Trevor.Dennis!

 

I opened one of these images in Photoshop and used the Trim command. That opened the Trim windows where I choiced the "Top left pixel color" option, selected "Top", "Left", "Right" and "Bottum" and cliked OK, but nothing is trimmed on the image. What's wrong acording you?

ajabon grinsmith
Community Expert
Community Expert
August 2, 2021

In your photo, you will find black lines and gray stains in the margins instead of simple white.

These interfere with the menu action "trim".
I think that only the image processor shown by Trevor has the potential to be processed automatically.

Geppetto Luis
Legend
July 31, 2021

go to the image / trim menu