4 Replies Latest reply on Jul 27, 2008 1:07 PM by (Keith_Cooper)

    (JS, CS2) Resizing images

      Hi!

      This is my first message, so first of all, thanks to all posters: I have already learned a lot from you.
      But to the point now:

      I have a problem I have never encountered before in ID CS2. I am helping with a facebook design (more than 2000 people). I have no idea how the whole thing was done from the beginning, but there's a following case: basically all the pictures in graphic frames are streched, so it looks like the wrong fitting was used while placing them. But strangely enough, just selecting the frame and choosing "fit contents proportionally" doesn't work. Actually no other way of fitting works - picture remains just as streched. The only way I can re-fit them is by selecting with the direct selection tool and changing width or height. Only then fitting works again. Of course I am not going to do it with every one of 2000+ pictures.
      b So my question is whether it can be done by scripting?
      And can someone provide me with directions and JS commands? I know there are JS fitting methods, but should they be applied to the graphic frame or to its content (if it's possible)?

      Thanks in advance!

      Kiri
        • 1. Re: (JS, CS2) Resizing images
          Loic.Aigon Adobe Community Professional
          Hi, you can definitely do this by script.<br />Weird that you can't manually fit the pictures clicking on the fitt options. It should produce a effect even if it's not the one you want. <br />if(app.documents.length > 0)<br />{<br />   var ad = app.activeDocument;<br />   if(ad.links.length > 0 )<br />   {<br />       var lk = ad.links;<br />       var lklg = ad.links.length;<br />       var lkcount = 0;<br /><br />       // loop passing through every links in the document;<br />       for(i=0; i<lklg; i++)<br />       {<br />          // Fit content to frame proportionnaly.<br />          ad.links[i].parent.fit(FitOptions.PROPORTIONALLY);<br /><br />          // Fit frame to content's new dimenions.<br />          ad.links[i].parent.fit(FitOptions.FRAME_TO_CONTENT);<br /><br />          lkcount += 1;  <br />       }<br />       alert(lkcount + " pictures processed");<br />    }<br />}<br />You just have to suit it to your needs.
          • 2. Re: (JS, CS2) Resizing images
            Level 1
            hi! thanks a lot for the links info, your script didn't work, but I have managed to do what I wanted with a small modification:<br /><br />{<br />   var ad = app.activeDocument;<br />   if(ad.links.length > 0 )<br />   {<br />       var lk = ad.links;<br />       var lklg = ad.links.length;<br />       var lkcount = 0;<br /><br />// loop passing through every links in the document;<br />       for(i=0; i<lklg; i++) { <br />             <br />             picture = ad.links[i];<br />               <br />               if (picture.parent != null) {<br />               hs = picture.parent.horizontalScale;<br />               picture.parent.resize (undefined, hs);<br />               picture.parent.parent.fit(FitOptions.fillProportionally);<br />               picture.parent.parent.fit(FitOptions.centerContent);<br />               }<br />}<br /><br />It does work on most images but on one it exits with a error about parent not being present. if != null statement I have tried doesn't work :(<br />b Is there any way to check for existance of parents?
            • 3. Re: (JS, CS2) Resizing images
              Loic.Aigon Adobe Community Professional
              Yes you can do this with exists method.
              if(File(picture.filePath).exists==true)
              ...
              Loic
              • 4. Re: (JS, CS2) Resizing images
                Does anyone know how to do the same with VB? My Javascript is really limited.