Skip to main content
Participant
December 15, 2021
Answered

How to save an alpha channel as jpg?

  • December 15, 2021
  • 5 replies
  • 7090 views

For several years, I saved and used "alpha channel" as an "export" function.

It was useful because various colors of "channel" were merged and stored at once.

 

Since the recent update, 'Export' has no longer been able to retrieve 'Alpha Channel'. 

Only 'layer' is retrieved from 'Export', so an empty screen is saved. Is there a solution?

 

I've tried reinstalling it to the previous version, but it's not solved.

Correct answer Steve5D7C

The JPG file format does not support alpha channels and never has.

5 replies

Stephen Marsh
Community Expert
Community Expert
December 22, 2021

 

The following script will save all alpha channels to JPEG from a single open, previously saved document – to the same location as the original document.

 

So myFilename.psd would save out as myFilename_Alpha 1.jpg myFilename_Alpha 2.jpg etc., using the name of the document and the name of each alpha channel with an underscore separator. Any existing files with the same name will be overwritten, use at your own risk.

 

/*
Save Open Doc Alphas to JPG.jsx
v1.0 - Stephen Marsh, 22nd December 2021
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-save-an-alpha-channel-as-jpg/td-p/12595286
How to save an alpha channel as jpg?
*/

#target photoshop

(function (){
    try {
        app.activeDocument.path;

        if (app.documents.length === 1) {
            try {
                if (app.activeDocument.mode === DocumentMode.RGB || app.activeDocument.mode === DocumentMode.LAB && app.activeDocument.channels.length > 3) {
                    processOpenDocs();
                } else if (app.activeDocument.mode === DocumentMode.CMYK && app.activeDocument.channels.length > 4) {
                    processOpenDocs();
                } else if (app.activeDocument.mode === DocumentMode.GRAYSCALE || app.activeDocument.mode === DocumentMode.DUOTONE || app.activeDocument.mode === DocumentMode.INDEXEDCOLOR && app.activeDocument.channels.length > 1) {
                    processOpenDocs();
                } else if (app.activeDocument.mode === DocumentMode.MULTICHANNEL) {
                    alert("Multichannel mode is not supported, please manually save the alpha channels!");
                } else {
                    alert("There are no alpha channels to save!");
                }
            } catch (err) {}

        } else {
            alert("This script only works with a single, previously saved doc open!");
        }

    } catch (err) {
        alert("This script only works with a single, previously saved doc open!");
    }
}());


////////// Functions //////////

function processOpenDocs() {
    var origDoc = app.activeDocument;
    origPath = app.activeDocument.path;
    var dupeName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
    app.activeDocument.duplicate(dupeName, true);
    
    app.activeDocument = origDoc;
    alert("The original document will now be closed...");
    var idclose = stringIDToTypeID("close");
    executeAction(idclose, undefined, DialogModes.ALL);
    
    convertToGrayscale();
    deleteChannel();
    splitChannels();
    
    while (app.documents.length > 0) {
    saveOpenDocs();
    }
    
    app.beep();
    alert("All alpha channels saved as JPEG files to:" + "\r" + origPath.fsName);
}

function convertToGrayscale() {
    var idconvertMode = stringIDToTypeID("convertMode");
    var desc640 = new ActionDescriptor();
    var idto = stringIDToTypeID("to");
    var idgrayscaleMode = stringIDToTypeID("grayscaleMode");
    desc640.putClass(idto, idgrayscaleMode);
    executeAction(idconvertMode, desc640, DialogModes.NO);
}

function deleteChannel() {
    var iddelete = stringIDToTypeID("delete");
    var desc621 = new ActionDescriptor();
    var idnull = stringIDToTypeID("null");
    var ref104 = new ActionReference();
    var idchannel = stringIDToTypeID("channel");
    var idordinal = stringIDToTypeID("ordinal");
    var idtargetEnum = stringIDToTypeID("targetEnum");
    ref104.putEnumerated(idchannel, idordinal, idtargetEnum);
    desc621.putReference(idnull, ref104);
    executeAction(iddelete, desc621, DialogModes.NO);
}

function splitChannels() {
    var idsplitChannels = stringIDToTypeID("splitChannels");
    var desc359 = new ActionDescriptor();
    executeAction(idsplitChannels, desc359, DialogModes.NO);
}

function saveOpenDocs() {
    var docName = app.activeDocument.name;
    var saveFileJPG = new File(new File(origPath + "/" + docName + ".jpg"));
    saveJPG(saveFileJPG);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

    function savePSD(saveFilePSD) {
        psdSaveOptions = new PhotoshopSaveOptions();
        psdSaveOptions.embedColorProfile = true;
        psdSaveOptions.alphaChannels = true;
        psdSaveOptions.layers = true;
        psdSaveOptions.annotations = true;
        psdSaveOptions.spotColors = true;
        app.activeDocument.saveAs(saveFilePSD, psdSaveOptions, true, Extension.LOWERCASE);
    }

    function saveJPG(saveFileJPG) {
        var jpgOptions = new JPEGSaveOptions();
        jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;
        jpgOptions.embedColorProfile = true;
        jpgOptions.matte = MatteType.NONE;
        jpgOptions.quality = 12;
        app.activeDocument.saveAs(saveFileJPG, jpgOptions, true, Extension.LOWERCASE);
    }
}

 

 

TheDigitalDog
Inspiring
December 15, 2021

Totally doable. But some steps needed:

Make the Alpha channel, in the Layers palette, use the "Split Channles" command, save the Alpha that results from the others as you desire.

You may wish to duplicate the document first, then split and discard all the other channels, while keeping the original intact.

The other way would be to make a selection and use Save Selection, >New document, in the dialog, then save it.

Author “Color Management for Photographers" & "Photoshop CC Color Management/pluralsight"
PECourtejoie
Community Expert
Community Expert
December 21, 2021

@TheDigitalDog indeed, but nothing prevents you to export them using the new export as. I'm really puzzled by the request, and how @지숙22258186n5dk does export his alpha channels with the old Export As.

D Fosse
Community Expert
Community Expert
December 15, 2021

AFAIK direct Export of alpha channels has never been possible. Might make for a good feature request.

 

What I've always done is target the channel and copy/paste into a new document.

 

Pay attention to your grayscale profiles! A single channel is effectively an untagged grayscale file, represented in your working gray. For consistency and some degree of predictability, you should probably set your working gray to Gray Gamma 2.2, or at any rate a gray space that has the same tone response curve as your document RGB.

JJMack
Community Expert
Community Expert
December 15, 2021

How did you save a channels as an image file? I used Phoroshop 2020 here and could not find a way to export an Alpha channels as a jpeg or export a Document as a Jpeg and have the saves Jpeg have a an exported Alpha channel.

JJMack
Steve5D7CCorrect answer
Inspiring
April 23, 2025

The JPG file format does not support alpha channels and never has.

PECourtejoie
Community Expert
Community Expert
December 15, 2021

Hi, I would suggest to try Edit/Preferences/Export and select "use legacy export as"

PECourtejoie
Community Expert
Community Expert
December 15, 2021

Mmh, I just tried, and I do not see an option to export the Channels in Legacy either...

Could you elaborate on how you were doing it?