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

Flatten image for all open documents

Community Beginner ,
Dec 26, 2021 Dec 26, 2021

Hello!

 

I often have this:

I open several files at once and create layers in them. Then I need to flatten image in all open documents.

Is it possible to make it at once and to write it down in the script?

 

Sincerely,

Niyetkhan

TOPICS
Actions and scripting
2.3K
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 , Dec 26, 2021 Dec 26, 2021

This version will just flatten all open docs, without saving or closing (probably closer to what you were looking for than the previous script).

 

/*
Use this script at your own risk!

Flatten image for all open documents
https://community.adobe.com/t5/photoshop-ecosystem-discussions/flatten-image-for-all-open-documents/m-p/12617518#M610710

Flatten All Open Files.jsx
Stephen Marsh, v1.0 - 26 December 2021
*/

#target photoshop

// CHECK FOR OPEN DOCS
if (app.documents.length) {

    // OPTIONAL
...
Translate
Adobe
Community Expert ,
Dec 26, 2021 Dec 26, 2021

I understand your workflow, however such as script is fraught with danger, so file under the cateogory of "be careful what you wish for"! This script will flatten, save and close all open docs, use at your own risk!

 

/*
Use this script at your own risk!

This script assumes that all open images have been previously saved from Photoshop.

Flatten image for all open documents
https://community.adobe.com/t5/photoshop-ecosystem-discussions/flatten-image-for-all-open-documents/m-p/12617518#M610710

Flatten Save & Close All Open Files.jsx
Stephen Marsh, v1.0 - 26 December 2021
*/

#target photoshop

// CHECK FOR OPEN DOCS
if (app.documents.length) {
    
    // OPTIONAL CONFIRMATION
    if (!confirm("Are you really sure that you wish to flatten, save and close all open docs?", false)) {
        //throw alert("Script cancelled!");
        throw null;
    }

    // LOOP OVER OPEN FILES
    while (app.documents.length > 0) {
        app.activeDocument.flatten();
        app.activeDocument.close(SaveOptions.SAVECHANGES);
    }

    // END OF SCRIPT NOTIFICATION
    app.beep();

// ALERT IF NO DOCS OPEN
} else {
    alert('You must have a document open!');
}

 

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
Community Expert ,
Dec 26, 2021 Dec 26, 2021

This version will just flatten all open docs, without saving or closing (probably closer to what you were looking for than the previous script).

 

/*
Use this script at your own risk!

Flatten image for all open documents
https://community.adobe.com/t5/photoshop-ecosystem-discussions/flatten-image-for-all-open-documents/m-p/12617518#M610710

Flatten All Open Files.jsx
Stephen Marsh, v1.0 - 26 December 2021
*/

#target photoshop

// CHECK FOR OPEN DOCS
if (app.documents.length) {

    // OPTIONAL CONFIRMATION
    if (!confirm("Are you really sure that you wish to flatten all open docs?", false)) {
        //throw alert("Script cancelled!");
        throw null;
    }

    // SET THE CURRENT DOC AS ORIGINAL DOC
    var actDoc = app.activeDocument;

    // LOOP OVER OPEN FILES
    for (var i = 0; i < app.documents.length; i++) {
        app.activeDocument = app.documents[i];
        app.activeDocument.flatten();
    }

    // RETURN TO THE ORIGINAL DOC
    app.activeDocument = actDoc;

    // END OF SCRIPT NOTIFICATION
    app.beep();
    alert("All open doc's layers have been flattened!")

    // ALERT IF NO DOCS OPEN
} else {
    alert('You must have a document open!');
}

 

 

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 ,
Dec 26, 2021 Dec 26, 2021
LATEST

Adobe installs a Photoshop Script that will do the for you in Photoshop. Photoshop menu File>Scripts>Image Processor... You can at the same time save layered versions of your  open documents by saving a PSD  or Tiff version as well as a flat jpeg file.

image.pngexpand image

 

JJMack
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