7 Replies Latest reply on Aug 13, 2018 9:32 AM by rob day

    Document Size from Image

    timothyg10570841 Level 1

      Is there a way to automatically/directly create an InDesign document the size of an image. We work with photoshop .psd and tiff files. It would expedite our workflow if it was possible to directly creation InDesign document from a tiff or psd file.

       

      If you drag a psd file onto After Effects app icon After Effects will create a new comp the size of the psd fileand place the psd file in the project menu.  It would be great if InDesign could behave the same way. 


      Perhaps someone knows a short cut for this. 

       

      While its not difficult to create a new InDesign document and then place a file in the document.  If you want an InDesign document to be the exact size of the image then you need to open the image and check the image size  and then enter the size dimensions when creating a new document.  Easy when sizes are simple but when sizes have decimal points the opportunity for mistakes is there. 

        • 1. Re: Document Size from Image
          Derek Cross Adobe Community Professional

          I’m intrigued to know why the facility you describe would be useful.

          • 2. Re: Document Size from Image
            winterm Level 5

            I wouldn’t hold my breath waiting when ID will be able to do this. Agree with Derek, it would hardly be useful for InDesign.

            You need to create a new doc at first, one way or another.

            While the second - fitting page to placed object - is doable, with Page tool, or the script.

            Read this article, and find Peter Kahrel’s comment with script provided below it.

            Notice Peter posted two versions of the script!

            • 3. Re: Document Size from Image
              timothyg10570841 Level 1

              We use InDesign for creating impositions of lenticular images.  During a proofing phase we need to create proofs that are the exact size of the lenticular image.  The sizes vary greatly.  Since we need to create the document the size of the image it would expedite the process if we could do it directly instead manually. 

              • 4. Re: Document Size from Image
                timothyg10570841 Level 1

                We know we are not the normal page layout user,  but it would be useful for us and I suspect there are others that could benefit. We were hoping that there might be a way since this functionality is present between Adobe Photoshop and Adobe After Effects.  It is also present between Adobe Photoshop and Adobe Illustrator.   You can drag an image file on the app and it will open the image in a document the exact size of image.

                • 5. Re: Document Size from Image
                  winterm Level 5

                  Different apps have different functionality, no surprise. Still not sure if you need InDesign here at all?

                  Whatever, in ID, I believe, Peter Kahrel's script is your best bet (in it's 2nd version). No need to check placed image dimensions, bother with document setup, nothing. Just drop image file on a page of any size, and click script's name in a panel, or assign KB shortcut to it.

                  FitPage.gif

                  • 6. Re: Document Size from Image
                    rob day Adobe Community Professional & MVP

                    I think it could be done with Applescript. What OS are you using?

                    • 7. Re: Document Size from Image
                      rob day Adobe Community Professional & MVP

                      This AppleScript (OSX only) seems to to work. It uses OSX's command line to get the chosen image's dimensions and makes a new ID doc to match. This would be harder with JavaScript, but might be possible by getting the image dimensions from Photoshop using BridgeTalk.

                       

                       

                       

                       

                      (*
                      Rob Day 2018
                      --Gets a chosen image's dimensions and makes a new ID doc with matching dimensions then places
                      *)
                      
                      
                      tell application "Adobe InDesign CC 2018"
                         
                          -------------------Get chosen file's width and height-----------------------
                          try
                              set f to (choose file with prompt "Select Image")
                              set w to my getImage(f, "pixelWidth")
                              set h to my getImage(f, "pixelHeight")
                             
                              -------------------Preferences for reset-----------------------
                             
                              set appviewprefs to properties of view preferences
                              set defpre to item 1 of every document preset whose name is "[Default]"
                              set defprop to properties of item 1 of defpre
                             
                              -------------------New Document with image placed-----------------------
                             
                              --setup document (height, width, margin-top, margin-right, margin-bottom, margin-left, bleed, columns, facing?, num pages)
                              my docSetup(h, w, 0, 0, 0, 0, 0, 1, false, 1)
                             
                              set exportdoc to make new document with properties {document preset:"[Default]"}
                              set myp to active page of layout window 1
                              place f on myp
                             
                              -------------------------------Reset----------------------------------
                             
                              set properties of view preferences to appviewprefs
                              set properties of item 1 of defpre to defprop
                             
                          on error
                              display dialog "Please choose an image file"
                              return -128
                          end try
                      end tell
                      
                      -------------------------------Functions----------------------------------
                      
                      --gets image info via command line
                      on getImage(fle, s)
                          tell application "Finder"
                              try
                                  set filePosixPath to quoted form of POSIX path of fle
                                  set infoString to do shell script ("sips -g " & s & " " & filePosixPath) as string
                              end try
                              set d to word 2 of paragraph 2 of infoString as number
                              return d
                          end tell
                      end getImage
                      
                      --set document units
                      on docSetup(h, w, mt, mr, mb, ml, b, c, fp, tp)
                          tell application "Adobe InDesign CC 2018"
                              set properties of view preferences to {horizontal measurement units:pixels, vertical measurement units:pixels, ruler origin:spread origin}
                              set properties of item 1 of every document preset whose name is "[Default]" to {document bleed bottom offset:b, document bleed uniform size:true, column count:c, bottom:mb, left:ml, right:mr, top:mt, pages per document:tp, page height:h, facing pages:fp, page width:w, start page number:1}
                          end tell
                      end docSetup