36

I have a largish PSD file with a couple of hundred layers, that I would like to extract selected areas from into PNG files.

Areas can consist of a couple of layers.

Being new to Photoshop, I have been using the following workaround. Duplicate needed layers into a new scratch PSD file of same size, TRIM to transparency, Save As PNG, undo TRIM, hide layers, rinse and repeat...

I suppose I could do it without the scratch file and just crop selection, Save As PNG and undo, but there must be a nicer method.

What other ways are there to accomplish this export of a selected area to PNG?

EDIT: This is on Windows Xp running Photoshop CS3 Extended

47
  • Make your selection
  • Edit -> Copy Merged
  • File -> New (Photoshop should automatically suggest a new canvas size to match the selection size)
  • Edit -> Paste
  • File -> Save As (PNG)
  • Rinse and repeat... (keyboard shortcuts are handy here)

(Tested on Photoshop CS4)

| improve this answer | |
  • 19
    Photoshop engineers should seriously think about improving this because it's tedious to do something so simple with 6 steps, it should have, at most, 2 steps, select and export. simple isn't it ? – Pedro Lobito May 15 '12 at 15:50
  • 4
    I beta test for Adobe for almost 10 years. I have asked for a new interface every single year. Photoshop UI is obtrusive, annoying, vintage from the nineties. At one time someone there asked me to stop asking for this stuff, because I was filling too many feature requests and creating "noise" on their system. How can I company bash a beta tester for suggesting improvements is beyond me. – Duck Jan 13 '14 at 8:33
  • Keyboard shortcuts for these steps: 1. ctrl + shift +c, 2. ctrl + n, 3. ctrl + v, 4. ctrl + s. 5. ctrl + w – Mahn Jul 22 '18 at 19:55
18

Try selecting the areas with the Slice tool and then File > Export for web & devices.

| improve this answer | |
  • I have been using this method more and more as compared to the original answer. Presumably, this is what Photoshop developers intended to be used for this particular problem. – Aniti Sep 4 '12 at 8:18
  • +1 better than the accepted answer, especially if you need to repeat this procedure a lot. – Amir Uval Apr 14 '15 at 17:04
  • 1
    this doesn't work for any selections that aren't rectangular and parallel to the edges of the image, whereas the above method works for all shapes and sizes – Lucas Jan 2 '16 at 0:22
  • @think123 True. Yet the resulting PNG is still rectangular. You could use a mask to make the shapes you want to have in the resulting Slice export. – Tomas Andrle Jan 2 '16 at 23:16
  • @TomasAndrle I am trying to extract scanned pictures - I have scanned four or so images together onto one large scan file, except these pictures were not positioned exactly straight, so it's difficult for me to slice them effectively. – Lucas Jan 2 '16 at 23:20
1

I tackled this by creating a script that I put in Presets\Scripts\Export Selection to PNG.jsx

The code as follows:

app.displayDialogs = DialogModes.NO;

var pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.compression = 9;

var hasSelection;
var docRef;
try {
    hasSelection = !!app.activeDocument.selection.bounds;
} catch (err) {
    hasSelection = false;
}

if (hasSelection) {
    app.activeDocument.selection.copy(true);
    var w = app.activeDocument.selection.bounds[2];
    var h = app.activeDocument.selection.bounds[3];
    docRef = app.documents.add(w, h);
    docRef.paste();
} else {
    docRef = app.activeDocument;
}
var file = File.saveDialog("Export as PNG to...");
if (file && ((file.exists && confirm("Overwrite " + file +"?")) || !file.exists)) {
    docRef.saveAs(file, pngSaveOptions, !hasSelection, Extension.LOWERCASE);
    if (hasSelection) {
    docRef.close(SaveOptions.DONOTSAVECHANGES);
    }
}

The script above will handle no-selection as a "select all" and checks if the target file exists confirming an overwrite.

This script is triggered from the File->Scripts->Export Selection to PNG

| improve this answer | |
-1

Make a selection. Then hit Ctr or CMD + J to copy that selection into a new layer. then:

File -> Scripts -> Export Layer to Files...

Export Layers to files

If your layer is smaller than the full width/height of the canvas don't forget to check Trim Layers.

| improve this answer | |
  • 1
    The question is not about exporting layers to files. It is about saving a selection as a file. The question specifically states "Areas can consist of a couple of layers." – Mike Fitzpatrick May 19 '12 at 5:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.