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

Export Layer Groups as PNGs and retain artboard size

New Here ,
Sep 20, 2021 Sep 20, 2021

Is there a way to batch export these layer groups as pngs?

I've tried 'Export As' but it trims the images into just what is visible in the group. I want to retain the size of the artboard (1080x1920) and keep the placement of my text where it is.

My workaround is creating layer comps and then exporting those as PNGs but it can be tedious to create a multitude of layer comps sometimes.

Any suggestions or has someone written a script?

 

Kristopher5E1B_1-1632191828758.png

Kristopher5E1B_2-1632192072682.png

 

 

TOPICS
Actions and scripting , macOS
7.1K
Translate
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 1 Correct answer

New Here , Sep 21, 2021 Sep 21, 2021

Hey, Thanks so much for this! I appreciate you taking the time.

I've given it a go but I was hoping for something that would export all of them at the same time.

My solution so far is using Generate - Image assets. Then adding .png to all my group names. I also had to add a layer mask to each group to stop it from trimming them into just the text. 

But the result is a folder that automatically generates the PNGs without having to export them.

Translate
Adobe
Explorer ,
Sep 20, 2021 Sep 20, 2021

Not sure how to automate it at the moment, but if you solo the group (alt+click the eyeball on windows, opt+click on Mac) so that only the layers you want are visible, you then deselect all the layers, and then do a quick export as png. You can adjust your "export as" extention in "Preferences/Export" to be png. Your exported file will maintain the canvas size and layer postion.

Fig. 1

LosoF_1-1632197447971.png

Fig. 2

LosoF_0-1632197373545.png

 

Translate
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 ,
Sep 21, 2021 Sep 21, 2021

I've created an action that will get you there partially.

You'll first want to save your file as it reverts back to it's starting point after each run. Then, in the layers panel,  select the group you want to export and run the action.

In short, it converts the group into a smart object to maintain the name of the group, and saves it as a png. You'll have to input your save location each time you run it, or follow the steps below to create a default save location. The link below has a video to the steps along with the action.

ACTION LINK

Translate
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
New Here ,
Sep 21, 2021 Sep 21, 2021

Hey, Thanks so much for this! I appreciate you taking the time.

I've given it a go but I was hoping for something that would export all of them at the same time.

My solution so far is using Generate - Image assets. Then adding .png to all my group names. I also had to add a layer mask to each group to stop it from trimming them into just the text. 

But the result is a folder that automatically generates the PNGs without having to export them.

Translate
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 ,
Sep 20, 2021 Sep 20, 2021

By the way, you can automate layer comps. Record action to create layer comps then export them. Collapse all groups before recording steps and before playing action. If you have different number of groups/layer comps per file then record action with two or three layer comps then play it multiple times or record action with lot of steps then exclude them from play, play only as much steps as you need.

After creating layer comps use Export > Layer Comps to Files. You can not record Export As as action step, by the way.

 

Translate
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 Beginner ,
Jan 29, 2025 Jan 29, 2025

Same problem here. This would really help...

 

adobe-pls.png

 

 

Translate
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 ,
Jan 29, 2025 Jan 29, 2025

@nitnat 

 

As this is a discussion, Adobe employees may not see this post.

 

You can create a new topic and label it as "Idea" rather than discussion or bug, then it can be voted on in a meaningful way.

 

BTW Adobe is aware that some users want better, flexible control of padding from within Export As (this has come up before), however, like many things to do with Export As – it's an unfinished work in progress.

Translate
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 ,
Jan 29, 2025 Jan 29, 2025
Translate
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
Advisor ,
Aug 10, 2025 Aug 10, 2025

Easiest the BG to use is "layer comps to files".. you need to make a layer comp of every group visible. Then export all or use selected. Pretty simple

Translate
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 ,
Aug 11, 2025 Aug 11, 2025
quote

...but it can be tedious to create a multitude of layer comps sometimes.

Any suggestions or has someone written a script?

 

 

By @Kristopher5E1B

 

The following script can be used to create a separate layer comp for each root/top-level group or artboard.

 

/*
Create a layer comp for each group or artboard.jsx
Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/export-layer-groups-as-pngs-and-retain-artboard-size/td-p/12394524
*/

#target photoshop

createLayerCompsForTopLevelGroups();

function createLayerCompsForTopLevelGroups() {
    if (!app.documents.length) {
        alert("No document is open!");
        return;
    }

    var doc = app.activeDocument;
    var layerComps = doc.layerComps;
    var topGroups = [];

    // Store original visibility state
    var visibilityState = [];

    // Collect only top-level layer sets or artboards
    for (var i = 0; i < doc.layerSets.length; i++) {
        if (doc.layerSets[i].parent == doc) {
            topGroups.push(doc.layerSets[i]);
        }
    }

    if (topGroups.length === 0) {
        alert("No top-level layer groups or artboards found!");
        return;
    }

    // Save original visibility of all top-level groups
    for (var i = 0; i < topGroups.length; i++) {
        visibilityState.push(topGroups[i].visible);
    }

    // Loop through each group and create a layer comp
    for (var i = 0; i < topGroups.length; i++) {
        var group = topGroups[i];

        // Hide all top-level groups
        for (var j = 0; j < topGroups.length; j++) {
            topGroups[j].visible = false;
        }

        // Show current group
        group.visible = true;

        // Create a Layer Comp
        var compName = group.name;
        layerComps.add(compName, group.name, true, true, true);
    }

    // Restore original visibility
    for (var i = 0; i < topGroups.length; i++) {
        topGroups[i].visible = visibilityState[i];
    }

    alert("Layer comps created for each top-level group/artboard.");
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

Translate
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
Advisor ,
Aug 11, 2025 Aug 11, 2025

@Stephen Marsh 

 

Do you have these scripts just lying around or do you custom build them here for people.

 

Kinda baffled you follow up so fast

Translate
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 ,
Aug 11, 2025 Aug 11, 2025
quote

@Stephen Marsh 

 

Do you have these scripts just lying around or do you custom build them here for people.

 

Kinda baffled you follow up so fast


By @schroef


Sometimes one or the other, but usually a bit of both. 

I have made scripts for processing all layers or all sets/artboards and I have also made scripts for layer comps. A lot of code can be reused. I liked Lego as a kid, so I tend to look at code like bricks.

Translate
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
Advisor ,
Aug 11, 2025 Aug 11, 2025

That's nice!

I combined layercomps and artboards to files into script.

I added your base code for wep export to it last week 🙂

Super nice!

Translate
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 ,
Aug 11, 2025 Aug 11, 2025
LATEST
quote

That's nice!

I combined layercomps and artboards to files into script.

I added your base code for wep export to it last week 🙂

Super nice!


By @schroef

 

Great stuff, I did see it:

https://github.com/schroef/Photoshop-Scripts

 

I've got a couple of AVIF scripts that I have been meaning to post, based off the previous WebP scripts...

 

Translate
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