Skip to main content
Participant
August 24, 2021
Answered

P: Export As now crops to contents instead of using the mask

  • August 24, 2021
  • 36 replies
  • 10994 views

I noticed in new version of Photoshop the Export As... function no longer uses the mask but instead crops to contents. 

For example if you make a group with a 512x512 mask, place an image inside it with some space around it, Export As does not export the 512x512 masked are but instead crops to the content image. 
I don't see how this is useful change as if you've masked the group and wanted to export only its contents you would just export the layer with contents, not the masked group.

There is a workaround though, you can switch back to Legacy Eport settings in preferences, but then again everyone who uses the psd has to do the same to get it working properly. 

Does anyone know another workaround for this that would not require switching to Legacy settings?

I can see this change causing issues to a lot of users and frankly can't see the benefits to this change.


 

Correct answer PECourtejoie

HEllo, I think this function exists only in the legacy export as function that you activate with the menu Edit Photoshop/Preferences/Export

36 replies

Participant
March 21, 2024

And another thing. This article explains You could alter the canvas size while exporting to have some control on the output size: https://helpx.adobe.com/photoshop/using/export-artboards-layers.html

 

But when I try this with an image inside an art board (so not just the canvas), the export window crashes.

Participant
March 21, 2024

Still no fix for this, Adobe? This really messes with our workflow here. We have to be able to export multiple Layer(folders) to PNG files while keeping control over the file size (in pixels) of those exports. That was possible by applying a mask to those layers to determine the size. 

 

We can not use the size of the canvas or art boards as suggested because the exports all need to have different sizes. Creating an artboard for each individual image would be crazy.

 

Please fix this.

clevermill.com
Inspiring
June 30, 2022

I certainly hope a solution is in the works.   My needs are the same as yours.

Inspiring
June 30, 2022

Is a permanent solution for this problem still in the works? We are exporting assets for games, and it's really important to have control over how a layer is placed within the canvas in that case. The assets are often not centered. The legacy export options work, but a proper solution would be much better of course.

Stephen Marsh
Community Expert
Community Expert
April 18, 2022
Stephen Marsh
Community Expert
Community Expert
March 23, 2022

@julieb28824091 – Unfortunately, there is no legacy Export As option for M1 Macs. You can use Rosetta or one of the other workarounds mentioned in this topic.

Stephen Marsh
Community Expert
Community Expert
March 23, 2022

This version works with selected layers:

 

/*
Transparency Bounding Pixels to Selected Layers.jsx
Stephen Marsh
Version 1, 5th March 2022
Adds a 1% white pixel to the upper left and lower right corners of the open document
Note: Assumes that the active layer is a raster layer that can be filled!
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/export-as-now-crops-to-contents-instead-of-using-the-mask/td-p/12336888
*/

//#target photoshop

if (documents.length) {
    var origRuler = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var docWidth = app.activeDocument.width.value;
    var docHeight = app.activeDocument.height.value;

    function main() {
        processSelectedLayers();
    }

} else {
    alert('There are no documents open!');
}

app.preferences.rulerUnits = origRuler;
app.activeDocument.suspendHistory("Run script", "main()");
app.runMenuItem(stringIDToTypeID("selectAllLayers"));
// Export As... don't use the file menu if you wish to save individually selected layers!
alert("Now use Export As... from the Layers panel to save the selected layers to PNG");


/*********** Functions ***********/

function processSelectedLayers() {
    var s2t = stringIDToTypeID;
    (r = new ActionReference).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
    r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
    var lrs = executeActionGet(r).getList(p),
        sel = new ActionReference();

    for (var i = 0; i < lrs.count; i++) {
        sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
        (r = new ActionReference).putIdentifier(s2t('layer'), p);
        (d = new ActionDescriptor()).putReference(s2t("target"), r);
        executeAction(s2t('select'), d, DialogModes.NO);

        if (!app.activeDocument.activeLayer.isBackgroundLayer) {
            try {
                addTransPixels();
            } catch (e) {}
        }

        function addTransPixels() {
            setSelection(0, 0, 1, 1);
            whiteFill(1.000000);
            app.activeDocument.selection.deselect();
            setSelection(docHeight - 1, docWidth - 1, docHeight, docWidth);
            whiteFill(1.000000);
            app.activeDocument.selection.deselect();
        }

        function setSelection(top, left, bottom, right) {
            var s2t = function (s) {
                return app.stringIDToTypeID(s);
            };
            var descriptor = new ActionDescriptor();
            var descriptor2 = new ActionDescriptor();
            var reference = new ActionReference();
            reference.putProperty(s2t("channel"), s2t("selection"));
            descriptor.putReference(s2t("null"), reference);
            descriptor2.putUnitDouble(s2t("top"), s2t("pixelsUnit"), top);
            descriptor2.putUnitDouble(s2t("left"), s2t("pixelsUnit"), left);
            descriptor2.putUnitDouble(s2t("bottom"), s2t("pixelsUnit"), bottom);
            descriptor2.putUnitDouble(s2t("right"), s2t("pixelsUnit"), right);
            descriptor.putObject(s2t("to"), s2t("rectangle"), descriptor2);
            executeAction(s2t("set"), descriptor, DialogModes.NO);
        }

        function whiteFill(fillOpacity) {
            var idfill = stringIDToTypeID("fill");
            var desc279 = new ActionDescriptor();
            var idusing = stringIDToTypeID("using");
            var idfillContents = stringIDToTypeID("fillContents");
            var idwhite = stringIDToTypeID("white");
            desc279.putEnumerated(idusing, idfillContents, idwhite);
            var idopacity = stringIDToTypeID("opacity");
            var idpercentUnit = stringIDToTypeID("percentUnit");
            desc279.putUnitDouble(idopacity, idpercentUnit, fillOpacity);
            var idmode = stringIDToTypeID("mode");
            var idblendMode = stringIDToTypeID("blendMode");
            var idnormal = stringIDToTypeID("normal");
            desc279.putEnumerated(idmode, idblendMode, idnormal);
            executeAction(idfill, desc279, DialogModes.NO);
        }
    }
}
Stephen Marsh
Community Expert
Community Expert
March 23, 2022

This version of the previous script works with all applicable layers:

 

/*
Transparency Bounding Pixels to All Layers.jsx
Stephen Marsh
Version 1, 5th March 2022
Adds a 1% white pixel to the upper left and lower right corners of the open document
Note: Assumes that the active layer is a raster layer that can be filled!
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/export-as-now-crops-to-contents-instead-of-using-the-mask/td-p/12336888
*/

#target photoshop

if (documents.length) {
    var origRuler = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var docWidth = app.activeDocument.width.value;
    var docHeight = app.activeDocument.height.value;

    function main() {
        selectFrontOrBackLayer("front", false);

        var lyrCount = app.activeDocument.layers.length;
        for (var i = 0; i < lyrCount; i++) {
            app.activeDocument.activeLayer = app.activeDocument.artLayers[i];
            // If layer isn't background
            if (!app.activeDocument.activeLayer.isBackgroundLayer) {
                try {
                    addTransPixels();
                } catch (e) {}
            }
        }

        app.runMenuItem(stringIDToTypeID("selectAllLayers"));
        // Export As... don't use the file menu if you wish to save individually selected layers!
        alert("Now use Export As... from the Layers panel to save the selected layers to PNG");
    }

    app.preferences.rulerUnits = origRuler;
    app.activeDocument.suspendHistory("Run script", "main()");

    /*********** Functions ***********/

    function addTransPixels() {
        setSelection(0, 0, 1, 1);
        whiteFill(1.000000);
        app.activeDocument.selection.deselect();
        setSelection(docHeight - 1, docWidth - 1, docHeight, docWidth);
        whiteFill(1.000000);
        app.activeDocument.selection.deselect();
    }

    function setSelection(top, left, bottom, right) {
        var s2t = function (s) {
            return app.stringIDToTypeID(s);
        };
        var descriptor = new ActionDescriptor();
        var descriptor2 = new ActionDescriptor();
        var reference = new ActionReference();
        reference.putProperty(s2t("channel"), s2t("selection"));
        descriptor.putReference(s2t("null"), reference);
        descriptor2.putUnitDouble(s2t("top"), s2t("pixelsUnit"), top);
        descriptor2.putUnitDouble(s2t("left"), s2t("pixelsUnit"), left);
        descriptor2.putUnitDouble(s2t("bottom"), s2t("pixelsUnit"), bottom);
        descriptor2.putUnitDouble(s2t("right"), s2t("pixelsUnit"), right);
        descriptor.putObject(s2t("to"), s2t("rectangle"), descriptor2);
        executeAction(s2t("set"), descriptor, DialogModes.NO);
    }

    function whiteFill(fillOpacity) {
        var idfill = stringIDToTypeID("fill");
        var desc279 = new ActionDescriptor();
        var idusing = stringIDToTypeID("using");
        var idfillContents = stringIDToTypeID("fillContents");
        var idwhite = stringIDToTypeID("white");
        desc279.putEnumerated(idusing, idfillContents, idwhite);
        var idopacity = stringIDToTypeID("opacity");
        var idpercentUnit = stringIDToTypeID("percentUnit");
        desc279.putUnitDouble(idopacity, idpercentUnit, fillOpacity);
        var idmode = stringIDToTypeID("mode");
        var idblendMode = stringIDToTypeID("blendMode");
        var idnormal = stringIDToTypeID("normal");
        desc279.putEnumerated(idmode, idblendMode, idnormal);
        executeAction(idfill, desc279, DialogModes.NO);
    }

    function selectFrontOrBackLayer(frontORback, makeVisible) {
        var s2t = function (s) {
            return app.stringIDToTypeID(s);
        };
        var descriptor = new ActionDescriptor();
        var list = new ActionList();
        var reference = new ActionReference();
        // "front" or "back"
        reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t(frontORback));
        descriptor.putReference(s2t("null"), reference);
        // true or false
        descriptor.putBoolean(s2t("makeVisible"), makeVisible);
        list.putInteger(1);
        descriptor.putList(s2t("layerID"), list);
        executeAction(s2t("select"), descriptor, DialogModes.NO);
    }

} else {
    alert('There are no documents open!');
}
Known Participant
March 23, 2022

Hey, @julieb28824091 

 

I can only offer a "work around". 

Go to programs, right click Photoshop and in the "information" menu – select open with Rosetta.  

 


That way it behaves like it used to for me. But it is also slower this way and there's a bug in this mode, where PS might crash if you try to move a shape's point and transform the shape into a regular path. (Can happen, but doesn't always.)

julieb28824091
Participant
March 23, 2022

Hello,

I would like to export a layer with a mask, in PNG, with my layer taking the size of the mask.

I could do it before, but now I have a new computer it doesn't work anymore, my element keeps its size but not the size of the mask.

Do you know how I can fix it please?

Thank you!

 

NB:

macOS Monterey - 12.2 // Photoshop 2022

PECourtejoie
Community Expert
PECourtejoieCommunity ExpertCorrect answer
Community Expert
March 23, 2022

HEllo, I think this function exists only in the legacy export as function that you activate with the menu Edit Photoshop/Preferences/Export