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

Crop single image

Engaged ,
Feb 08, 2025 Feb 08, 2025

Copy link to clipboard

Copied

This is something I also struggled with in Photoshop for years.

Can't we just crop a single image that we have in our document?

Using the layer mask is not ideal, because if I then want to resize the image, it includes the space taken by the mask (unless I'm missing something?)

Yes, I can select, invert, delete. But why so many steps? Also, if the image goes beyond the document's borders, it only deletes what's visible.

What I usually do now is I select, create a new layer only with that selection, delete the layer underneath it. Again, why so many steps for something that could be achieved with a single tool or shortcut?

 

Why is it that Adobe hasn't included a tool or shortcut just for this? Any idea? This seems to be such a basic thing a lot of us use, that's why I can't really wrap my head around why it isn't possible.

TOPICS
macOS

Views

168
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 ,
Feb 08, 2025 Feb 08, 2025

Copy link to clipboard

Copied

Crop is by definition document-level, not individual layer-level.

 

To "crop" on an individual layer, you make a mask. The mask can be unlinked. That way you can always go back.

 

To do it permanently, the easy solution is to select > invert selection > delete.

Votes

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 ,
Feb 08, 2025 Feb 08, 2025

Copy link to clipboard

Copied

Thank you for the reply, and I don't want to sound "rude", but you just pointed out all the obvious things I already now, but didn't answer my questions:
Why would Adobe not include this as a shortcut or a tool? Is there an obvious reason besides "this is how it works since the beginning and they are not willing to change"? I understand the whole "non-destructive" approach, but if that's the case, why give us alternative ways to destructively do it with the Select>Invert>Delete, or even the Eraser tool? So I don't think that the "non-destructive" logic would apply.

 

Unlinking the mask doesn't do what I would expect, though. If my image is 100px by 100px and I create a mask that's 25px by 25px, and I want to resize the visible portion (masked), how would I do that? When I use the Transform option, it's showing me the whole 100px by 100px boundaries. How can I just resize the 25px by 25px using the Transform tool? This is what frustrates me the most in Photoshop, to be honest. I totally understand that having the option to resize all can and is useful, but isn't it also useful to have a visual cue of what my actual masked section is being resized to?

 

Also, as I mentioned, the solution you provided isn't perfect. When the image is bigger than the document, using the Select, Invert, Delete, will only delete the visible postion of the image, not what's outside the canvas.

 

Again, not trying to be rude or anything, I'm just looking for some clarification, without getting answers and "solutions" to things I already know and stated in my post.

 

Thank you.

Votes

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 ,
Feb 08, 2025 Feb 08, 2025

Copy link to clipboard

Copied

I just asked ChatGPT to create a script for that, and after some trial and error, it seems to be working:

// Photoshop Script: Copy Selection to New Layer and Delete Original (Preserve Position)

var doc = app.activeDocument;
var activeLayer = doc.activeLayer;

// Get selection bounds
var selectionBounds = doc.selection.bounds;
var x = selectionBounds[0];
var y = selectionBounds[1];

doc.selection.copy();
var newLayer = doc.artLayers.add();
doc.paste();

// Move pasted selection to original position
doc.activeLayer.translate(x - doc.activeLayer.bounds[0], y - doc.activeLayer.bounds[1]);

activeLayer.remove();

 

I would still like it to be natively, but in any case, for someone looking for the same thing, here it is. I'm not an expert in scripts, so if there's something that can be improved, please suggest. 

With the script, we can always assign a shorcut to is, so it's perfect.

 

Anyway, if someone can show me a way to resize a masked section by not showing the boundaries of the whole image, that would be great.

Votes

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 ,
Feb 08, 2025 Feb 08, 2025

Copy link to clipboard

Copied

quote

I just asked ChatGPT to create a script for that, and after some trial and error, it seems to be working... I'm not an expert in scripts, so if there's something that can be improved, please suggest. 


By TiagoRocha

 

I added some extras to the code, however, there are arguably better options below:

 

* Single history step

* Check for selection

* Paste in Place

* Rename the new layer to the original layer name

 

// Photoshop Script: Copy Selection to New Layer and Delete Original (Preserve Position)

#target photoshop

// Single history stage undo
activeDocument.suspendHistory("Undo script", "main()");

function main() {

    // Selection check
    var theSelection = null;
    try {
        theSelection = activeDocument.selection.bounds;
    } catch (e) {
        alert("The script requires a selection..."); 
    }

        // Global Variables
        var doc = app.activeDocument;
        var origLayer = doc.activeLayer;
        var origLayerName = origLayer.name;

        // Create the new layer via copy + paste in place
        doc.selection.copy();
        var s2t = function (s) { return app.stringIDToTypeID(s); };
        var descriptor = new ActionDescriptor();
        descriptor.putBoolean(s2t("inPlace"), true);
        executeAction(s2t("paste"), descriptor, DialogModes.NO);

        // Delete original layer
        origLayer.remove();

        // Rename new layer to original layer name
        app.activeDocument.activeLayer.name = origLayerName;

}

 

That being said, a 2-step action or script could be used instead:

 

1) Convert the masked layer to a Smart Object

2) Rasterize the layer

 

#target photoshop

// Single history stage undo
activeDocument.suspendHistory("Undo script", "main()");

function main() {

    // Convert to a Smart Object
    executeAction(stringIDToTypeID("newPlacedLayer"), undefined, DialogModes.NO);

    // Rasterize the Smart Object
    executeAction(stringIDToTypeID("rasterizePlaced"), undefined, DialogModes.NO);

}

 

Or even better, a single-step action or script:

 

1) Layer > Layer Mask > Apply

 

#target photoshop

// Apply layer mask
var s2t = function (s) {
	return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "mask" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor.putBoolean( s2t( "apply" ), true );
executeAction( s2t( "delete" ), descriptor, DialogModes.NO );

 

Votes

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 ,
Feb 08, 2025 Feb 08, 2025

Copy link to clipboard

Copied

LATEST
quote

Can't we just crop a single image that we have in our document?

Using the layer mask is not ideal, because if I then want to resize the image, it includes the space taken by the mask (unless I'm missing something?)

...

Why is it that Adobe hasn't included a tool or shortcut just for this? Any idea? This seems to be such a basic thing a lot of us use, that's why I can't really wrap my head around why it isn't possible.


By TiagoRocha

 

There may be a translation issue when you use the term "image" – the context really means "layer" and "crop" is really "mask".

 

Only Adobe can answer "why"... I suspect that this has to do with non-destructive editing. The methods previously mentioned are destructive.

 

Smart objects can achieve a non-destructive workflow and allow you to resize the layer to the cropped area without the overall bounding area of the original layer's pixel content being transformed.

 

1) Add a Layer Mask to the raster layer content

2) Convert the raster layer to a Smart Object

 

Now when you transform, the masked area is used, not the entire layer bounding area.

 

If you need to revert to the original layer's raster content:

 

1) Edit the Smart Object

2) Delete the layer mask

3) Image > Reveal All

4) Close and save the Smart Object .psb file

 

All of these steps are easily recorded into an action or script.

Votes

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