14 Replies Latest reply on Aug 1, 2017 2:48 AM by SuperMerlin

    How to separate Fidget Spinner Export JPG files Scripting

    saranr37921948 Level 1

      How to do export files JPG

       

      any script or any other method

       

      18 output JPG files

       

      this is for the Test file PSD file link Fidget Spinner Test Files - Google Drive

       

      kindly advise

       

      Screen Shot 2017-07-27 at 5.56.11 PM.png

      Screen Shot 2017-07-27 at 11.59.14 PM.png

      output files:

      Screen Shot 2017-07-28 at 12.05.48 AM.png

        • 1. Re: How to separate Fidget Spinner Export JPG files Scripting
          saranr37921948 Level 1

          anybody understand my requirement

          • 2. Re: How to separate Fidget Spinner Export JPG files Scripting
            saranr37921948 Level 1

            anybody give solution this

             

            i stuck

             

            how to do this

             

            Photoshop variable or any script

            • 4. Re: How to separate Fidget Spinner Export JPG files Scripting
              saranr37921948 Level 1

              very best comedy Sir

               

              I want solution

               

              I am learn scripting

              • 5. Re: How to separate Fidget Spinner Export JPG files Scripting
                JJMack Most Valuable Participant

                saranr37921948  wrote

                 

                very best comedy Sir

                 

                I want solution

                 

                I am learn scripting

                I was not trying to be a comic.  You posted a layered PSD file that has three layers one each has a an image of a single spinner. One Red, one Green, one blue,  You posted you want 18 spinners jpg and poster 19 row two column list containing 18 file names and an associated color red, green, or blue. You ask if any one understood your requirements.  You want jpeg from ]from Photoshop.  What Photoshop steps are you trying to script. Show us what you have so far so we get some Idea of the process you are trying to automate. You gave us no information as to how you want the generate these files. You ask ho to separate the spinners. Your PSD has them on separate layers. They seem to be separated already??? One of your appends also seemed to indicate you may be using Photoshop data driven graphics for you stated Photoshop variable  which goes along with a PSD and a Row and Column CSV file. However, your PSD does not look like a Data Driver Graphics template. I think the only one who understand what you want may be yourself.

                • 6. Re: How to separate Fidget Spinner Export JPG files Scripting
                  Stephen_A_Marsh Adobe Community Professional

                  JJMack, my “understanding” is:

                   

                  Create a script to cycle through a red, green, blue layered file. The script should perform a lookup from a .CSV file matching the “Fidget Spinner Color” column value to the appropriate layer name to switch on visibility and save out a new file with the name found in the “File Naming” column for that colour.

                   

                  If this was only 18 files, this could have easily be done manually in less than 5 minutes, so I’m guessing that this is either an ongoing requirement or the list is actually a lot longer than 18 files.

                  • 7. Re: How to separate Fidget Spinner Export JPG files Scripting
                    JJMack Most Valuable Participant

                    That could be what they want. It is just hard for me to believe they want five copies of a red spinner image, five copies of a blue spinner and eight copies of a green spinner  with coded file names like they show.

                    rgbspinners.png

                    • 8. Re: How to separate Fidget Spinner Export JPG files Scripting
                      saranr37921948 Level 1

                      i don't know how to explain in english

                      kindly see the screenshot I want this kind of output

                       

                      Create a script to cycle through a red, green, blue layered file. The script should perform a lookup from a .CSV file matching the “Fidget Spinner Color” column value to the appropriate layer name to switch on visibility and save out a new file with the name found in the “File Naming” column for that colour.

                      Screen Shot 2017-07-29 at 9.52.22 AM.png

                      • 9. Re: How to separate Fidget Spinner Export JPG files Scripting
                        saranr37921948 Level 1

                        thank you sir my requirement you understand

                         

                        this is my requirement

                         

                        Create a script to cycle through a red, green, blue layered file. The script should perform a lookup from a .CSV file matching the “Fidget Spinner Color” column value to the appropriate layer name to switch on visibility and save out a new file with the name found in the “File Naming” column for that colour.

                         

                        I have 1000 files:)

                        • 10. Re: How to separate Fidget Spinner Export JPG files Scripting
                          JJMack Most Valuable Participant

                          You do not need Photoshop to do file copying. All you would be doing with that script is copying your three images.  It would be very easy with a text editor to make a DOS BAT file using your CVS file to copy the three images jpeg files you started with.  You do not need complicate things  stack the images into a layered document then script the process.  It a simple file copy you are doing..

                          • 11. Re: How to separate Fidget Spinner Export JPG files Scripting
                            SuperMerlin Level 5
                            #target photoshop;
                            app.bringToFront();
                            
                            if(documents.length) main();
                            function main(){
                            var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
                            var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
                            if(csv == null) return;
                            outputFolder = Folder.selectDialog("Please select the output folder");
                            if(outputFolder == null) return;
                            csv.open('r');
                            var data = csv.read();
                            csv.close();
                            data=data.split("\n");
                            var data2=[];
                            for(var a in data){
                                if(a==0) continue;
                                var line = data[a].split(",");
                                if(line.length ==2)
                                data2.push([[line[0].toString().replace(/^\s+|\s$/g,"").replace(/File Name$/,Name)],[line[1].toString().replace(/^\s+|\s$/g,"")]]);
                                }
                            data=[];
                            setLayersVisOFF();
                            for(var x in data2){
                                if(selectLayerByName(data2[x][1].toString())){
                                app.activeDocument.activeLayer.visible = true;
                                var saveFile = new File(outputFolder +"/" + data2[x][0].toString() + ".jpg");
                                SaveForWeb(saveFile,80);
                                app.activeDocument.activeLayer.visible = false;
                                }
                                }
                            };
                            function setLayersVisOFF(){ 
                               var ref = new ActionReference(); 
                               ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); 
                               var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1; 
                            try{
                                activeDocument.backgroundLayer;
                            var i = 0; }catch(e){ var i = 1; };
                               for(i;i<count;i++){ 
                                    ref = new ActionReference(); 
                                    ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
                                    var desc = executeActionGet(ref);
                                    var layerName = desc.getString(charIDToTypeID( 'Nm  ' ))
                                    if(layerName.match(/^<\/Layer group/) ) continue;
                                    var layerType = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'layerSection' )));
                                    var isLayerSet =( layerType == 'layerSectionContent') ? false:true;
                                    if(desc.getBoolean(stringIDToTypeID('visible')) && isLayerSet != true){
                                        var list = new ActionList();
                                        list.putReference( ref );
                                        desc.putList( charIDToTypeID('null'), list );
                                        executeAction( charIDToTypeID('Hd  '), desc, DialogModes.NO );
                                        }
                               }; 
                            };
                            function selectLayerByName(lyrName){ 
                            var desc = new ActionDescriptor(); 
                            var ref = new ActionReference(); 
                            ref.putName( charIDToTypeID( "Lyr " ), lyrName); 
                            desc.putReference( charIDToTypeID( "null" ), ref ); 
                            desc.putBoolean( charIDToTypeID( "MkVs" ), false ); 
                            try{
                            return executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO ); 
                            }catch(e){return null;}
                            }; 
                            function SaveForWeb(saveFile,jpegQuality) {
                            var sfwOptions = new ExportOptionsSaveForWeb(); 
                               sfwOptions.format = SaveDocumentType.JPEG; 
                               sfwOptions.includeProfile = false; 
                               sfwOptions.interlaced = 0; 
                               sfwOptions.optimized = true; 
                               sfwOptions.quality = jpegQuality;
                            activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
                            };
                            
                            
                            
                            2 people found this helpful
                            • 13. Re: How to separate Fidget Spinner Export JPG files Scripting
                              saranr37921948 Level 1

                              the script not taking the file name the original file

                               

                              the script now taking the CVS filenaming

                               

                              I want taking the CVS to File Naming + original PSD file name

                               

                              Example naming

                               

                              MVI_FidgetSpinner.jpg

                               

                              Screen Shot 2017-08-01 at 12.07.27 PM.png

                               

                              output came this kind of not taking the file name

                              Screen Shot 2017-08-01 at 12.10.21 PM.png

                               

                              kindly edit the script

                               

                              thank you for your help

                              • 14. Re: How to separate Fidget Spinner Export JPG files Scripting
                                SuperMerlin Level 5
                                #target photoshop;
                                app.bringToFront();
                                
                                if(documents.length) main();
                                function main(){
                                var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
                                var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
                                if(csv == null) return;
                                outputFolder = Folder.selectDialog("Please select the output folder");
                                if(outputFolder == null) return;
                                csv.open('r');
                                var data = csv.read();
                                csv.close();
                                data=data.split("\n");
                                var data2=[];
                                for(var a in data){
                                    if(a==0) continue;
                                    var line = data[a].split(",");
                                    if(line.length ==2)
                                    if(line[0].toString().replace(/^\s+|\s$/g,"").match(/File Name$/)){
                                    data2.push([[line[0].toString().replace(/^\s+|\s$/g,"").replace(/File Name$/,Name)],[line[1].toString().replace(/^\s+|\s$/g,"")]]);
                                    }else{
                                       data2.push([[(line[0].toString().replace(/^\s+|\s$/g,"") +"_" +Name)],[line[1].toString().replace(/^\s+|\s$/g,"")]]);
                                       }
                                    }
                                data=[];
                                setLayersVisOFF();
                                for(var x in data2){
                                    if(selectLayerByName(data2[x][1].toString())){
                                    app.activeDocument.activeLayer.visible = true;
                                    var saveFile = new File(outputFolder +"/" + data2[x][0].toString() + ".jpg");
                                    SaveForWeb(saveFile,80);
                                    app.activeDocument.activeLayer.visible = false;
                                    }
                                    }
                                };
                                function setLayersVisOFF(){ 
                                   var ref = new ActionReference(); 
                                   ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); 
                                   var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1; 
                                try{
                                    activeDocument.backgroundLayer;
                                var i = 0; }catch(e){ var i = 1; };
                                   for(i;i<count;i++){ 
                                        ref = new ActionReference(); 
                                        ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
                                        var desc = executeActionGet(ref);
                                        var layerName = desc.getString(charIDToTypeID( 'Nm  ' ))
                                        if(layerName.match(/^<\/Layer group/) ) continue;
                                        var layerType = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'layerSection' )));
                                        var isLayerSet =( layerType == 'layerSectionContent') ? false:true;
                                        if(desc.getBoolean(stringIDToTypeID('visible')) && isLayerSet != true){
                                            var list = new ActionList();
                                            list.putReference( ref );
                                            desc.putList( charIDToTypeID('null'), list );
                                            executeAction( charIDToTypeID('Hd  '), desc, DialogModes.NO );
                                            }
                                   }; 
                                };
                                function selectLayerByName(lyrName){ 
                                var desc = new ActionDescriptor(); 
                                var ref = new ActionReference(); 
                                ref.putName( charIDToTypeID( "Lyr " ), lyrName); 
                                desc.putReference( charIDToTypeID( "null" ), ref ); 
                                desc.putBoolean( charIDToTypeID( "MkVs" ), false ); 
                                try{
                                return executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO ); 
                                }catch(e){return null;}
                                }; 
                                function SaveForWeb(saveFile,jpegQuality) {
                                var sfwOptions = new ExportOptionsSaveForWeb(); 
                                   sfwOptions.format = SaveDocumentType.JPEG; 
                                   sfwOptions.includeProfile = false; 
                                   sfwOptions.interlaced = 0; 
                                   sfwOptions.optimized = true; 
                                   sfwOptions.quality = jpegQuality;
                                activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
                                };
                                
                                
                                
                                1 person found this helpful