Quantcast
Channel: Adobe Community : Unanswered Discussions - Photoshop
Viewing all articles
Browse latest Browse all 74445

Why duplicating activeDocument before calling saveAs() ?

$
0
0

Reading the scripts supplied with photoshop CS6, namly "Layer Comps To Files.jsx", the save functionality is implemented as following quoted below. I'm wondering why do the script needs to duplicate the activeDocument?

 

 

// Copyright 2007.  Adobe Systems, Incorporated.  All rights reserved.

 

            for ( compsIndex = 0; compsIndex < compsCount; compsIndex++ ) {

                var compRef = docRef.layerComps[ compsIndex ];

                if (exportInfo.selectionOnly && !compRef.selected) continue; // selected only

                compRef.apply();

                var duppedDocument = app.activeDocument.duplicate();

                var fileNameBody = exportInfo.fileNamePrefix;

 

 

                fileNameBody += compRef.name;

                if (null != compRef.comment) fileNameBody += "_" + compRef.comment;

                fileNameBody = fileNameBody.replace(/[:\/\\*\?\"\<\>\|\\\r\\\n]/g, "_"); // '/\:*?"<>|\r\n' -> '_'

                if (fileNameBody.length > 120) fileNameBody = fileNameBody.substring(0,120);

                saveFile(duppedDocument, fileNameBody, exportInfo);

                duppedDocument.close(SaveOptions.DONOTSAVECHANGES);

            }

 

 

          function saveFile( docRef, fileNameBody, exportInfo) {

               // ...

               docRef.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);

               // ...

          }

 

 

 

What effects of calling saveAs on the active document has for the user?


Viewing all articles
Browse latest Browse all 74445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>