1 Reply Latest reply on Jun 28, 2011 9:41 AM by AgsmithMS

    JS CS5 InDesign Server - struggling with Graphic.resize()

    AgsmithMS

      My goal:

      To place an image onto a document at a specified location, and resizing it to specified dimensions.

       

      My problem:

      When I resize the image, the frame does not "grow" to accomodate the new dimensions.  This results in my image getting cropped.

       

      My script:

      var inddfile = new File(app.scriptArgs.getValue("inputfilepath"));
      var logofile = new File(app.scriptArgs.getValue("logofilepath"));
      var outputFile = new File(app.scriptArgs.getValue("outputfilepath"));
      var logoX = app.scriptArgs.getValue("logoX");
      var logoY = app.scriptArgs.getValue("logoY");
      var logoWidth = app.scriptArgs.getValue("logoWidth");
      var logoHeight = app.scriptArgs.getValue("logoHeight");
      var myDocument = app.open(inddfile);
      
      var mypage = myDocument.pages.item(0);
      var viewprefs = myDocument.viewPreferences;
      viewprefs.horizontalMeasurementUnits = MeasurementUnits.POINTS;
      viewprefs.verticalMeasurementUnits = MeasurementUnits.POINTS;
      
      var testGraphic = myDocument.pages.item(0).place(logofile, [parseFloat(logoX), parseFloat(logoY)])[0];
      
      testGraphic.resize(CoordinateSpaces.INNER_COORDINATES,
                         AnchorPoint.CENTER_ANCHOR,
                         ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,
                         [200, 200]);
      
      myDocument.exportFile(ExportFormat.JPG, File(outputFile));
      myDocument.close(SaveOptions.no);
      
      

       

       

      I have tried using reframe(CoordinateSpaces.INNER_COORDINATES, [[0,0],[200,200]]) as well, but the results are the same.

       

      I apologize if this has been answered elsewhere.  I'm also sure that the answer to my question is documented somewhere, but I'm really at my wit's end.  Can someone please point out what I am missing?  Also, I am attaching a couple of example images to help display my problem.

       

      Thank you

       

      Image without resizing:

      before resize.JPG

       

      Image WITH resizing:

      after resize.JPG