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

Help - Cannot have multiple layers within a smart object - Forcing me to Flatten Image

Community Beginner ,
Apr 08, 2025 Apr 08, 2025

Hi there,
Until the last update (Photoshop to 26.5) I could have multiple layers within a smart object.
Now when I do that, and then click save .. I get an error message, telling me I need to flatten the images inorder to save and update smart object.

I usually need multiple layers WITHIN a smart object when creating my mockups. To flatten the layers is a destructive way of working.
Does any one know how to work around this?  Is there a setting I need to select/unselect?

smart object.jpg

TOPICS
Windows
125
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

Community Expert , Apr 08, 2025 Apr 08, 2025

Your issue results from placing a jpeg file in your document which embeds it as a smart object. The smart object in that case is a jpeg and cannot contain layers. What you could do is use Save As to save the edited smart object as a separate document in a format that does support layers e.g. PSD or TIFF, then place that document in your original document as a new smart object layer.

 

Dave

Translate
Adobe
Community Expert ,
Apr 08, 2025 Apr 08, 2025

Your issue results from placing a jpeg file in your document which embeds it as a smart object. The smart object in that case is a jpeg and cannot contain layers. What you could do is use Save As to save the edited smart object as a separate document in a format that does support layers e.g. PSD or TIFF, then place that document in your original document as a new smart object layer.

 

Dave

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
Adobe Employee ,
Apr 08, 2025 Apr 08, 2025

I refreshed the page, and you've laid out the facts already. 

Sameer 

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 ,
Apr 08, 2025 Apr 08, 2025
LATEST

Here is a script to automate the manual steps:

 

* Edit the embedded smart object layer

* Save As a copy to a temporary PSB file (or PSD)

* Close the edited smart object

* Replace the embedded smart object with the PSB

* Delete the temporary PSB

 

https://community.adobe.com/t5/photoshop-ecosystem-ideas/editing-and-saving-a-dynamic-object-with-mo...

 

/*
Create Embedded PSB from Smart Object Layer 1-2.jsx
Stephen Marsh
v1.0 - 14th March 2025: Initial release
v1.1 - 6th April 2025: Added a check to ensure that only Embedded Smart Objects are processed
v1.2 - 7th April 2025: Added a check to ensure that the Embedded Smart Object is supported by Photoshop for editing
https://community.adobe.com/t5/photoshop-ecosystem-ideas/editing-and-saving-a-dynamic-object-with-more-layers/idc-p/15210208
INFO: Run this script on an Embedded Smart Object to replace it as a PSB file (example, automatically convert an embedded JPEG to PSB so that it can accept layers).
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-ideas/save-multilayer-png-jpg-smart-objects-as-psb-and-automatically-replace/idi-p/12504206
*/

#target photoshop;

try {

    // Check if a document is open
    if (app.documents.length === 0) {
        throw new Error("Error: A document must be open!");
    }

    // Check if the active layer is a Smart Object
    if (app.activeDocument.activeLayer.kind != LayerKind.SMARTOBJECT) {
        throw new Error("Error: The layer isn't a Smart Object!");
    }

    // Additional AM code checks for the Smart Object
    var ref = new ActionReference();
    ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
    var layerDesc = executeActionGet(ref);
    ref.putProperty(charIDToTypeID("Prpr"), stringIDToTypeID("smartObject"));
    ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
    var so = executeActionGet(ref).getObjectValue(stringIDToTypeID("smartObject"));
    var soMoreDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObjectMore'));

    // Check if the Smart Object is a Generative AI layer
    if (soMoreDesc.hasKey(stringIDToTypeID('generativeDocInfo')) === true) {
        throw new Error("Error: A Generative Fill Smart Object isn't a supported layer type!");
    }

    // Check if the Smart Object is linked
    if (so.getBoolean(stringIDToTypeID("linked")) === true) {
        throw new Error("Error: A Linked Smart Object isn't a supported layer type!");
    }

    // Check if the embedded Smart Object is a supported for direct editing in Photoshop, and not a raw camera file or container file (e.g. PDF, EPS, AI)
    var theSOlayer = app.activeDocument.activeLayer;
    ref.putIdentifier(charIDToTypeID("Lyr "), theSOlayer.id);
    var desc = executeActionGet(ref);
    var smObj = desc.getObjectValue(stringIDToTypeID("smartObject"));
    var fileRef = smObj.getString(stringIDToTypeID("fileReference"));
    var fileExtension = fileRef.match(/\.([a-zA-Z0-9]+)$/i)[1];
    var validExtensions = /^(psd|psb|jpeg|jpg|tiff|tif|tga|png|webp|gif)$/i;

    if (validExtensions.test(fileExtension)) {

        // Edit the original embedded SO
        app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));

        // Create a temp folder with a name based on datetime
        function pad(number, length) {
            var str = '' + number;
            while (str.length < length) {
                str = '0' + str;
            }
            return str;
        }

        function getFormattedDateTime() {
            var now = new Date();
            var day = pad(now.getDate(), 2);
            var month = pad(now.getMonth() + 1, 2); // Months are zero-based
            var year = now.getFullYear();
            var hours = pad(now.getHours(), 2);
            var minutes = pad(now.getMinutes(), 2);
            var seconds = pad(now.getSeconds(), 2);
            var milliseconds = pad(now.getMilliseconds(), 3);
            return day + month + year + hours + minutes + seconds + milliseconds;
        }

        var timestamp = getFormattedDateTime();
        var theTempDir = new Folder("~/Desktop/_theTempDir_" + timestamp);
        if (theTempDir.exists) {
            throw new Error("Error: Script cancelled as the temporary desktop folder already exists!");
        }

        theTempDir.create();

        // Save the open edited embedded image to a temp PSB file
        var thePSB = theTempDir + "/" + app.activeDocument.name.replace(/\.[^\.]+$/, '') + ".psb";
        function s2t(s) {
            return app.stringIDToTypeID(s);
        }
        var descriptor = new ActionDescriptor();
        var descriptor2 = new ActionDescriptor();
        descriptor2.putBoolean(s2t("maximizeCompatibility"), true);
        descriptor.putObject(s2t("as"), s2t("largeDocumentFormat"), descriptor2);
        descriptor.putPath(s2t("in"), new File(thePSB));
        descriptor.putBoolean(s2t("lowerCase"), true);
        descriptor.putEnumerated(s2t("saveStage"), s2t("saveStageType"), s2t("saveSucceeded"));
        executeAction(s2t("save"), descriptor, DialogModes.NO);
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

        // Replace the original embedded file with the temp PSB file
        descriptor = new ActionDescriptor();
        descriptor.putPath(s2t("null"), new File(thePSB));
        executeAction(s2t("placedLayerReplaceContents"), descriptor, DialogModes.NO);

        // Remove the temp PSB before the temp folder can be removed
        thePSB = new File(thePSB);
        thePSB.remove();

        // Remove the empty temp folder
        theTempDir.remove();

        // End of script notification
        // alert("The embedded Smart Object has been replaced with a PSB file!");
        app.beep();

    } else {
        throw new Error("Error: The embedded Smart Object isn't a supported file type for automated PSB replacement!");
    }

} catch (e) {
    alert(e.message);
}

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save as a plain text format file – .txt
  5. Rename the saved file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

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