6 Replies Latest reply on Oct 8, 2018 7:16 PM by Stephen_A_Marsh

    Copy image width and open with photoshop

    Klaas vT Level 1

      Hi,

      I have a document with a few hundred pages, and part of our standard workflow (do other people do this?) is to resize all the images to the print size (at 300ppi) in Photoshop, then sharpen for printing, then relink all images to the resized ones (so that the effective ppi of all images is 300ppi).

       

      It seems like this would be made a lot less tedious by some simple scripting, so can someone help me get started? for now I just want to:

      - copy the width of the image contained in the selected frame in mm to the clipboard

      - open the file in Photoshop

       

      I have an action in PS to take care of the resizing, so it's another keyboard shortcut, then paste in the width when the resize image dialogue pops up.

       

      Eventually, I could imagine the script doing this, but I feel like I'm asking too much to do it all at once now!

      - select first image

      - if it is over or under 300dpi, open it in PS and run an action (with user input)

      - go back to ID select the next image untill all are done

      - relink all images to the new folder

       

      Thanks already!

      K

        • 1. Re: Copy image width and open with photoshop
          Benreyn Level 1

          I don't know much about Photoshop or scripting for it, I assume it is similar but different than InDesign just like scripting for Illustrator. However, the script below will loop through the current opened and active document in InDesign and determine if a pageItem is a graphic(image) frame, read the PPI of the image which then will kick-off what it needs to do with the image in Photoshop (I believe using DoScript action via standalone script built for Photoshop goes here (provided from somewhere else beside me as I mentioned I do not know PS scripting)), then the final part is updating all the out-of-date links in the InDesign document.

           

          var doc = app.activeDocument;

           

          for(var i = 0; i < doc.pages.length; i++) {

              var items = doc.pages.item(i).pageItems.everyItem().getElements();

              if(items) {

                  for(var j = 0; j < items.length; j++) {

                     if(items[j] == "[object TextFrame]") {

                         //Found a Text frame do nothing

                     } else if (items[j] == "[object Group]") {

                         //Found a Group do nothing (if image frame is in a grouping you will need to ungroup (code can achieve this but not currently doing as such and will skip said image(s)))

                     } else if (items[j] == "[object GraphicLine]") {

                         //Found a Graphic Line do nothing

                     } else {

                         // Item found is a Image Frame lets do something!

                          if(doc.pages.item(i).pageItems.item(j).graphics.length) {

                              var ePpi = doc.pages.item(i).pageItems.item(j).images.item(0).effectivePpi[0]; //Read PPI of image

                                  if(ePpi < 300) {

                                      //ADD PHOTOSHOP SCRIPTING HERE SUCH AS A "DoScript" TO HANDLE WHAT PHOTOSHOP NEEDS TO DO FOR IMAGES LESS THAN 300 PPI

                                  } else if(ePPi >300) {

                                      //ADD PHOTOSHOP SCRIPTING HERE SUCH AS A "DoScript" TO HANDLE WHAT PHOTOSHOP NEEDS TO DO FOR IMAGES MORE THAN 300 PPI

                                  } else {

                                    // Image is 300 PPI do nothing??

                                 }

                          }

                      }

                  }

              }  

          }

           

          updateLinks();

           

          function updateLinks() {

              for (var x = doc.links.length-1; x >= 0; x--) {

                  var link = doc.links[x];

                  if (link.status == LinkStatus.linkOutOfDate) {

                      link.update();

                  }

              }

          }

          1 person found this helpful
          • 2. Re: Copy image width and open with photoshop
            Klaas vT Level 1

            Hi Benreyn,

            That's a really good start, it'll help already... For now the only action I'd need in the script would be to copy the actual width of the image contianed in the image frame to the clipboard, execute the "edit original" or "open with Photoshop", and then pop an alert() so the script waits till I come back to do the next one.

             

            Can anyone add that?

            • 3. Re: Copy image width and open with photoshop
              S Hopkins Adobe Community Professional

              Hi

              Another idea for you. On Macintosh you can use Image Events to scale the image with resolution. You pass it the length of the longest side of the image (in inches decimal) times 300 (resolution). I would suggest putting the file's path and the resize factor into a list so you could batch process the files and do the updates each as a separate function. Here's the Image Events routine passing the processList (filePath, resizeFactor):

              on doImageEvents(processList)

                 repeat with i from 1 to length of processList

                    set filePath to item 1 of item i of processList

                    set resizeFactor to item 2 of item i of processList

                    tell application "Image Events"

                       set thisImage to open file filePath

                       try

                          scale thisImage to size resizeFactor

                          save thisImage in filePath

                          close thisImage

                       on error

                          close thisImage

                       end try

                    end tell

                 end repeat

              end doImageEvents

              • 4. Re: Copy image width and open with photoshop
                Laubender Adobe Community Professional & MVP

                Hi,

                would that AppleScript work for "every" kind of pixel image?

                JPEG, TIFF, also PSD?

                 

                Or only for "flat" image data without any layers, vector paths for cropping etc.pp. ?

                 

                ( Currently I'm not on a Mac so I cannot test the code right away )

                 

                Best,
                Uwe

                • 5. Re: Copy image width and open with photoshop
                  S Hopkins Adobe Community Professional

                  Hi,

                  Thanks for the question. I have used Image Events with jpeg, tiff, and layered psd's with no problems. I am sure some of the psd's I have worked with had vector paths. I will pull out some images and test further.

                  Shirley

                  • 6. Re: Copy image width and open with photoshop
                    Stephen_A_Marsh Adobe Community Professional

                    I have a document with a few hundred pages, and part of our standard workflow (do other people do this?) is to resize all the images to the print size (at 300ppi) in Photoshop, then sharpen for printing, then relink all images to the resized ones (so that the effective ppi of all images is 300ppi).

                     

                    I wrote the following in 2009:

                     

                    “As a prepress operator, I have handled one or two layouts over the last two decades. In the past, it was more common for artists to build layouts with images at or close to final reproduction size (give or take say +/- 20%), with appropriate output sharpening applied for the image content and output/viewing conditions. Today, in my experience this is rarely the case, many layouts contain unsharpened images that have been scaled in the layout to either high or low extremes, rather than being sized and placed at the final 100% magnification.”

                     

                    Prepression: Scripting Adobe InDesign

                     

                    Today I would usually export to PDF with a 240 or 300ppi resolution threshold and then use Enfocus PitStop Pro to globally output sharpen all images.

                     

                    Of course, critical “hero” images may be individually worked, however the bulk of the images are probably not worth the effort.

                    1 person found this helpful