19 Replies Latest reply on Nov 4, 2016 9:01 AM by mauricior6328708

    Auto save a new document

    mauricior6328708 Level 1

      Hello personal greetings to all!

      I have some images to be printed on some products ... For this I have to create a new document and add corresponding mascaras to size prints, then have to save these documents (backup) in the same folder of the last inserted picture. I have two questions:

       

       

      1st: There is how to create a script to auto save the document?

      2nd: Whenever I run this script in the same document, the same self rename. Example: document-01.jpeg .... document-02.jpeg ... document-03.jpeg ...

      Already, I thank you for your help.

      I'll leave some illustrations to better understand.

      estampa.jpg

      folder.jpg

        • 1. Re: Auto save a new document
          JJMack Most Valuable Participant

          I see no product. You illustration seems to show a Composite image opened, a new document created to house  two copies of the composite image rotated  90 degrees and positioned side by side and saved with some name you want. That process could be scripted.

          • 2. Re: Auto save a new document
            elyasafo28436183 Level 1

            This works for me..

             

            #target photoshop
            
            
            var folder_path = "~/desktop/something/";
            // Change here the path to your fokler.
            
            
            if (app.documents.length > 0){
                app.activeDocument = app.documents[0];
                
                var fold = new Folder(folder_path);
                if (!fold.exists) fold.create();
            
            
                var i = 0;
                while (true){
                    f_name = folder_path + app.documents[0].name.slice(0,-4);
                    f = new File(f_name +"_"+i+".jpg");
                    if (!f.exists) break;
                    i++;
                }
                
                savePng(f_name+"_"+i);
            }
            function savePng(name){
                var doc = app.activeDocument;
                
                saveOptions = new JPEGSaveOptions;
                
                var f = new File (name);
                
                doc.saveAs (f, saveOptions, true);
            }
            
            1 person found this helpful
            • 3. Re: Auto save a new document
              mauricior6328708 Level 1

              That's right Mr. Jack! Printing via sublimatic paper.

              Caneca-Porcelana_print.jpg

              • 4. Re: Auto save a new document
                mauricior6328708 Level 1

                Thank elyasafo28436183! Your script worked 50% sure, it saves copies perfectly ... It would work 100% if the document was saved in the folder where the file used in the document ... He always saved on the desktop. Is there a way to fix as my need.?

                • 5. Re: Auto save a new document
                  elyasafo28436183 Level 1

                  Of course..

                   

                  edit the the 4th line to -

                   

                  var folder_path = app.activeDocument.path +'/';
                  
                  
                  • 6. Re: Auto save a new document
                    mauricior6328708 Level 1

                    I made the change and this message appears

                    Untitled-1.jpg

                    • 7. Re: Auto save a new document
                      elyasafo28436183 Level 1

                      The document has not yet been saved..

                      So the script don't know where to save the images..

                      • 8. Re: Auto save a new document
                        mauricior6328708 Level 1

                        If you create a new document, insert an image and then asked to save, it shows you the folder that image ..... This is not possible through script?

                        • 9. Re: Auto save a new document
                          JJMack Most Valuable Participant

                          In my Photo Collage Toolkit package there is a script I wrote to populate a Multi Image collage psd template with a single image that will be populated into every image location in the Collage template and rotate images for best fit given the two aspect ratios. The Images aspect ratio and the Collage template image locations aspect ration. Fitted image look like centered corps. If Aspect ratios match no part of the image will be masked off.  I created that script for Adobe has removed their Picture Package Plug-in from Photoshop.  My script will work as a substitute for picture package however it requires a template and has higher overhead  then Adobe Picture Package had.

                           

                          So it would be easy to create a two image side by side collage pad template file.  Then Batch populate the template with all your images.

                           

                          Photo Collage Toolkit

                           

                          Photoshop scripting is powerful and I believe this package demonstrates this A video showing a 5 image collage PSD template  being populated with images:

                           

                          The package includes four simple rules to follow when making Photo Collage Template PSD files so they will be compatible with my Photoshop scripts.

                          1. Size the photo collage templates for the print size you want - width, height and print DPI resolution.
                          2. Photo collage templates must have a Photoshop background layer. The contents of this layer can be anything.
                          3. Photo collage templates must have alpha channels named "Image 1", "Image 2", ... "Image n".
                          4. Photo collage templates layers above the background layers must provide transparent areas to let the images that will be placed below them show through.

                           

                          There are fifteen scripts in this package they provide the following functions:

                          1. HelpPhotoCollageToolkit.jsx - Online Help
                          2. TestCollageTemplate.jsx - Used to test a Photo Collage Template while you are making it with Photoshop.
                          3. CollageTemplateBuilder.jsx - Can build Templates compatible with this toolkit's scripts.
                          4. LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document.
                          5. InteractivePopulateCollage.jsx - Used to interactively populate Any Photo Collage template. Offers most user control inserting pictures and text.
                          6. ReplaceCollageImage.jsx - use to replace a populated collage image Smart Object layer with an other image correctly resized and positioned.
                          7. ChangeTextSize.jsx - This script can be used to change Image stamps text size when the size used by the populating did not work well.
                          8. PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
                          9. BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
                          10. BatchMultiImageCollage.jsx - Used to Automatically Batch Populate Any Photo Collage template with images in a source image folder. Easier to use than the interactive script. Saved collages can be tweaked.
                          11. PasteImageRoll.jsx - Paste Images into a document to be print on roll paper.
                          12. BatchPicturePackage.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder.  Images Rotates for best fit.
                          13. BatchPicturePackageNoRotate.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder.
                          14. PopulatePicturePackage.jsx - Used to Automatically populate a Photo Collage template Fill with the same single image and leave the populated copy open in Photoshop.
                          15. PCTpreferences.jsx - Edit This File to Customize Collage Populating scripts default setting and add your own Layer styles.

                           

                          Documentation and Examples

                          • 10. Re: Auto save a new document
                            mauricior6328708 Level 1

                            JJMack Thank you for your attention and for trying to help me, but not quite what I need.

                            • 11. Re: Auto save a new document
                              JJMack Most Valuable Participant

                              If you download my toolkit and install it. All you need to do is create a Collage PSD template file. All it would need to have is a background layer that has a canvas size and resolution to house your two side be side images.   There  also need to be two alpha channels one to  map each image shape size and location.  Batch populate that template using item 12 above Script BatcPicturePackage.jsx

                              • 12. Re: Auto save a new document
                                mauricior6328708 Level 1

                                What I need is just a script that creates a backup of the document in the same folder as the arquvios.

                                http://pastebin.com/raw/eKDfnY5u

                                This script work fine, I just need to program for it to save in the same folder of images used.

                                You need not do anything, only resize the directory of the image used in the current document.

                                • 13. Re: Auto save a new document
                                  JJMack Most Valuable Participant

                                  You can get that path from the active document,

                                  • 14. Re: Auto save a new document
                                    mauricior6328708 Level 1

                                    When creating a new document after we insert a picture, to save the document, it directs you exactly to the folder containing the last entered file. The point is that I use a lot of images in several different folders. Manually it would be impossible. I would not have to automate this process?

                                    Just as was automatically redirected to a folder on the desktop, it could be redimencionado "saved" in the same folder where the image used is located.

                                    • 15. Re: Auto save a new document
                                      JJMack Most Valuable Participant

                                      The script you posted has a hard codes output folder variable.  You would set ths vaiiable dynamiclly when you start pricessing an input image. You would get its file path and set the output folder variable.

                                      • 16. Re: Auto save a new document
                                        natrev Level 3

                                        Hi Mauricior,

                                         

                                        Run this code and this script will ask for folder to proceed JPG conversion.

                                        After ran, the final file saved into same folder with name of "JPG" under folder

                                         

                                        Try this code..

                                         

                                        #target Photoshop 
                                        main();
                                        function main(){
                                            app.preferences.rulerUnits = Units.PIXELS;
                                            app.preferences.typeUnits = TypeUnits.PIXELS; 
                                            app.displayDialogs = DialogModes.NO;
                                            var myFolder = Folder.selectDialog ("Select Source Folder to Proceed!");
                                            if(!myFolder){return;}
                                            var myFiles = myFolder.getFiles(/\.(jpg|tif|eps|psd)$/i);
                                            if(myFiles.length==0){alert("No files to use this folder!"); return;}
                                            for(var i = 0; i < myFiles.length; i++){    
                                                var docRef=app.open(myFiles[i]);
                                                var docPath=myFiles[i].path;
                                                var dname=myFiles[i].name;
                                                fileName=decodeURI(dname).replace(/\.[^\.]+$/, '');
                                                Ext=(i<10) ? "0"+ (i+1)  : (i+1);
                                                fileName=fileName+"_Porcelana_print_"+Ext;            
                                                OutFoldJPG(docPath+"/JPG",fileName,12,true,Extension.LOWERCASE);
                                                docRef.close(SaveOptions.DONOTSAVECHANGES);
                                            };
                                        }
                                        function OutFoldJPG(docPath,dnme,jpegQuality,cProfile,formatType,fCase){ 
                                            var outfolder = new Folder(docPath)
                                            if (outfolder.exists == false){
                                                outfolder.create();
                                                var saveFile = new File(outfolder + "/" + dnme);
                                                SaveJPEG(saveFile,jpegQuality,cProfile,fCase);
                                            }
                                            else{
                                                var saveFile = new File(outfolder + "/" + dnme);
                                                SaveJPEG(saveFile,jpegQuality,cProfile,fCase);
                                            }
                                        }
                                        function SaveJPEG(saveFile, jpegQuality,cProfile,fCase){
                                            jpgSaveOptions = new JPEGSaveOptions();
                                            jpgSaveOptions.embedColorProfile = cProfile;
                                            jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
                                            jpgSaveOptions.matte = MatteType.NONE
                                            jpgSaveOptions.quality = jpegQuality; //1-12
                                            activeDocument.saveAs(saveFile, jpgSaveOptions, true,fCase);
                                        }
                                        

                                         

                                         

                                        -yajiv

                                        • 17. Re: Auto save a new document
                                          mauricior6328708 Level 1

                                          Hello Natrev, thank you for the help! Your script is very good and will I be very useful in other jobs.

                                           

                                           

                                          What I need is just a script que Creates a backup of the document in the same folder of the arquvios.

                                          http://pastebin.com/raw/eKDfnY5u

                                          This script works well, the problem is that it does not save in the same folder as the image used in the current document. Thank you!

                                          If you can test this script, you'll see that it actually works but the backup is created on the desktop.

                                          folder.jpg

                                          • 18. Re: Auto save a new document
                                            natrev Level 3

                                            Hi Mauricior,

                                             

                                            Change the 18th line code

                                            OutFoldJPG(docPath+"/JPG",fileName,12,true,Extension.LOWERCASE);
                                            

                                             

                                            to this line

                                             

                                            OutFoldJPG(docPath,fileName,12,true,Extension.LOWERCASE);
                                            

                                             

                                            Its save the file with in same native folder.

                                             

                                            cheers...

                                             

                                            -yajiv

                                            1 person found this helpful
                                            • 19. Re: Auto save a new document
                                              mauricior6328708 Level 1

                                              Hello guys, I want to thank everyone who tried to help me .... Thank you for your attention. Unfortunately I did not get the expected result. I thought it best to take a break in this matter. A hugs to everyone.