3 Replies Latest reply on Apr 22, 2015 8:00 AM by mirza h

    resize all images in document

    mirza h

      Hello,

       

      I have long document with 300+ images. I need to re size them all to W=63,5 mm and H=53 mm. I dig the Forum and find out this script from user "Harbs." but it is for re scaling images to certain percent:

       

      This will scale all images to 90% of their current size:

        myGraphics = app.activeDocument.allGraphics;   for (idx = 0; myGraphics.length > idx; idx++) {    if(myGraphics[idx].constructor.name!="Image"){continue}    myGraphics[idx].parent.horizontalScale = 90;    myGraphics[idx].parent.verticalScale = 90;   } 

       

      And this will scale them to an absolute 90%:

        myGraphics = app.activeDocument.allGraphics;   for (idx = 0; myGraphics.length > idx; idx++) {    if(myGraphics[idx].constructor.name!="Image"){continue}    myGraphics[idx].horizontalScale = 90;    myGraphics[idx].verticalScale = 90;    myGraphics[idx].parent.fit(FitOptions.FRAME_TO_CONTENT);   }

       

      Anyone knows how to make it to resize the images to specific size?

       

      Thanks!

        • 1. Re: resize all images in document
          rob day Adobe Community Professional & MVP

          Setting width and height is a bit more complicated because you have to calculate the bounds (there isn't a width and height property for an image). I can't do it off the top of my head with javascript, but if you're using OSX this Applescript would resize from the upper left corner.

           

          tell application "Adobe InDesign CC 2014"

              tell active document

                  set properties of view preferences to {horizontal measurement units:millimeters, vertical measurement units:millimeters}

                  repeat with x in all graphics

                      set {a, b, c, d} to geometric bounds of x

                      set geometric bounds of x to {a, b, a + 53, b + 63.5}

                      tell parent of x

                          fit given frame to content

                      end tell

                  end repeat

              end tell

          end tell

          • 2. Re: resize all images in document
            rob day Adobe Community Professional & MVP

            For JS this might work. Make sure your rulers are set to mm:

             

            for(var i=0; i < app.activeDocument.allGraphics.length; i++){

                var a=app.activeDocument.allGraphics[i].geometricBounds[0];

                var b=app.activeDocument.allGraphics[i].geometricBounds[1];

                var c=app.activeDocument.allGraphics[i].geometricBounds[2];

                var d=app.activeDocument.allGraphics[i].geometricBounds[3];

                app.activeDocument.allGraphics[i].geometricBounds=[a,b,a+53,b+63.5];

                app.activeDocument.allGraphics[i].parent.fit(FitOptions.FRAME_TO_CONTENT)

            }

            • 3. Re: resize all images in document
              mirza h Level 1

              Thanks a lot! I'm on windows, Indesign CC. I will try JS!