13 Replies Latest reply on Aug 4, 2017 7:52 AM by JJMack

    Unable to auto process batch images for Mobile Case Mockup. Please help.

    rohits64093926

      I am trying to batch process mockup images.

       

      I made a set of actions:

      Open

      Edit Contents

      Place

      Flatten Image

      Save

      Update Smart Object

      Close

       

      But I am getting an error stating "edit objects not available" and if trying another way then "x object not available"

       

      I have attached images for reference please help me. I am badly stuck. !photoshop mockup screenshot.png

        • 1. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
          JJMack Most Valuable Participant

          Actions are not scripts they are step step step. When played and fail ina step loot at the action pallets step and the state of the current document to see what went wrong.  Posting your action would help

          • 2. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
            rohits64093926 Level 1

            Hi!

             

            I have attached a image of the actions I have created. In the actions the main issue is the place file is not replacing with the other images. It is only picking up the same image and making all the mockups with the same 1st image. !Actions.png

            • 3. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
              JJMack Most Valuable Participant

              Place, does not replace it places in a new smart object layer. And that place step will always place in the file recorded in the step 2.jpg.

              • 4. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                rohits64093926 Level 1

                Hello! Ok got it so how can this be solved? What should be used instead of place?

                • 5. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                  natrev Level 3

                  Hi Rohit,

                   

                  Try this code...

                   

                  #target photoshop  
                  if (app.documents.length > 0) {  
                      var docRef = app.activeDocument;  
                      var theName = docRef.name.match(/(.*)\.[^\.]+$/)[1];  
                      var docPath = docRef.path;  
                      var theLayer = docRef.layers.getByName('YOUR CASE');  ;  
                      // check if layer is smart object;  
                      if (theLayer.kind != "LayerKind.SMARTOBJECT") {  
                          alert("selected layer is not a smart object")  
                      } else {  
                          // select files;  
                          var theFolder = Folder.selectDialog("select folder");  
                          if (theFolder) {  
                              var theFiles = theFolder.getFiles(/\.(jpg|tif|eps|psd|png)$/i);              
                              // work through the array;  
                              for (var m = 0; m < theFiles.length; m++) {  
                                  // replace smart object;  
                                  theLayer = replaceContents(theFiles[m], theLayer);  
                                  var theNewName = theFiles[m].name.match(/(.*)\.[^\.]+$/)[1];                  
                                  //save jpg;  
                                  OutFoldJPG(docPath,theNewName+".jpg",true,12,FormatOptions.STANDARDBASELINE,Extension.LOWERCASE,"JPG"); 
                              }  
                          };  
                      }  
                  };  
                  
                  
                  function replaceContents(newFile, theSO) {  
                      app.activeDocument.activeLayer = theSO;      
                      var idplacedLayerReplaceContents = stringIDToTypeID("placedLayerReplaceContents");  
                      var desc3 = new ActionDescriptor();  
                      var idnull = charIDToTypeID("null");  
                      desc3.putPath(idnull, new File(newFile));  
                      var idPgNm = charIDToTypeID("PgNm");  
                      desc3.putInteger(idPgNm, 1);  
                      executeAction(idplacedLayerReplaceContents, desc3, DialogModes.NO);  
                      return app.activeDocument.activeLayer  
                  };  
                  function OutFoldJPG(docPath,dnme,cProfile,jpegQuality,MType,fCase,flagFormat){ //OutFoldTIFF(filePath,fileName,true,TIFFEncoding.TIFFLZW,Extension.LOWERCASE)  
                      var outfolder = new Folder(docPath+"/"+flagFormat);        
                      if (outfolder.exists == false){
                          outfolder.create();
                          var saveFile = new File(outfolder + "/" + dnme);            
                          SaveJPG(saveFile,cProfile,jpegQuality,MType,fCase);}
                      else{
                          var saveFile = new File(outfolder + "/" + dnme);
                          SaveJPG(saveFile,cProfile,jpegQuality,MType,fCase);}
                  }
                  function SaveJPG(saveFile, jpegQuality,cProfile,formaType,fCase){//12,true,MatteType.NONE
                      //alert(saveFile+"\n"+cProfile+"\n"+jpegQuality+"\n"+fCase+"\n"+formaType);
                      jpgSaveOptions = new JPEGSaveOptions();
                      jpgSaveOptions.embedColorProfile=cProfile;
                      jpgSaveOptions.formatOptions = formaType//FormatOptions.STANDARDBASELINE;
                      jpgSaveOptions.matte =  MatteType.NONE
                      jpgSaveOptions.quality = jpegQuality; //1-12
                      activeDocument.saveAs(saveFile, jpgSaveOptions, true,fCase);
                  }
                  
                  
                  
                  
                  

                   

                  - yajiv

                  • 6. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                    JJMack Most Valuable Participant

                    If you want to use replace content of a smart object layer.  All replacement object must be exactly the same size and resolution as the object in the template mockup file.  A script would be needed to automate that process.  I like to be able to handle any size image. So my templates only map the size location and shape of image using alpha channels Your images will be placed in by my scripts as smart object layers then the scripts will resize the placed in images position them and mask them to shape.. 

                    • 7. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                      rohits64093926 Level 1

                      Hi

                       

                      Thanks for script!

                       

                      The script is working but only a part of the image is being fitted in the mockup after zooming. The image sizes are 960 px x 1896 px. Only a part of the image is being showed on the mockup. When replacing it is not picking up the original size of the jpg which is 960 px x 1896 px. It is making the image very big which is 4635px X 7975px. 

                       

                      How can we solve this?

                      • 8. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                        SuperMerlin Level 5

                        It will fail as you have a "Flatten Image" doing this you will no longer have a smart object.

                        • 9. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                          rohits64093926 Level 1

                          Hi

                           

                          Can you provide me a script for this?

                           

                          Thanks.

                          • 10. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                            JJMack Most Valuable Participant

                            Smart object layers have an associated transform,  All replacements must be the same size and resolution as the original object in the mock. They will all be transformed like the mockup object. The smart object associated transform is not replaced or altered when you replace smart object layers content.  All replacement images need to be preprocesses to have the same aspect ratio and number of pixels as the original object. That is why I do not use replace contents populating mockup.  I place in smart object layers set their transform to resize and position the images then mask it to shape.

                            • 11. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                              JJMack Most Valuable Participant

                              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

                              • 12. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                                rohits64093926 Level 1

                                Hi

                                 

                                The script is working! But the quality output is not good. The file size is 103 Kb but while doing one manually the file size is 950 Kb. The size is being reduced. The size is being reduced of the jpg while saving. Please help out with this.

                                 

                                Thanks in advance!

                                • 13. Re: Unable to auto process batch images for Mobile Case Mockup. Please help.
                                  JJMack Most Valuable Participant

                                  Scripts are Automated Photoshop processes that are added to Photoshop like  Actions and Plug-in like Fitters like ACR and other add-ons.   Photoshop ships with some scripts  you may have used. Like Photomerge, Lens correction, .Fit Image, Merge to HDR Pro,  Image Processor, Load  Files into a stack., etc  They are Photoshop tools and like other  tools may have dependencies.  Like to use My scripts on you need create templates and use templates that follow my design rules  or you need to download templates the do..