Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Exact size Image frame dimensions script

Return to Member Forum

  • Author
    Posts
    • #1240292

      Hi all,

      I’m after a script to be built or pointers to an existing or help to build one please.

      Is there way to scale a range of selected graphic frames, so they are the same height or same width and the other X/Y scale in proportion. Keeping the graphic scaled in the frame.

      I have a bunch of logos on a page (pages of the things) that are all placed at different sizes and scales. I am after trying to make them either the same height or same width.

      Example say for heights.
      Frame One is 25mm high
      Frame Two is 45mm high
      Frame Three is 25.135354mm high
      Frame Four is 9mm high

      All frames need to be 20mm high with the width scaled in proportion.

      I may need a case where all widths would be uniform, with different heights in proportion.

      So I guess it’ll need some dialogue pop-up to allow me to put in a height or width.

      I’m more than happy to write this myself but I’ll need some major hand-holding.
      Also I’m happy to buy someone a beer (coffee-tea-larger-orange) or three if they fancy writing this for me

      Cheers Bill

    • #1240318
      David Blatner
      Keymaster
    • #1240338

      Hi David! Thanks for the reply.

      Unfortunately because the graphic frames are pre-populated, the images do not scale with the frames. I think this is going to need a script. I can’t use the auto fit feature as some graphics may themselves already be scaled or positioned in the frames.

      Bill

    • #1240348
      David Blatner
      Keymaster
    • #1240398

      Thanks David, but this doesn’t do a job.

      I will though plod on and if I make something then I will post it here as i really think this will be a handy tool.

      bill

    • #1240428
      Brian Pifer
      Participant

      Here’s the dialog built with the handy scriptUI builder: https://scriptui.joonas.me/

      Should help you get started.

      // DIALOG
      // ======
      var dialog = new Window(“dialog”);
      dialog.text = “TableStyler”;
      dialog.orientation = “column”;
      dialog.alignChildren = [“left”,”top”];
      dialog.spacing = 10;
      dialog.margins = 16;

      // GROUP1
      // ======
      var group1 = dialog.add(“group”, undefined, {name: “group1”});
      group1.orientation = “column”;
      group1.alignChildren = [“left”,”center”];
      group1.spacing = 10;
      group1.margins = 0;

      var radiobutton1 = group1.add(“radiobutton”, undefined, undefined, {name: “radiobutton1”});
      radiobutton1.text = “Height”;

      var radiobutton2 = group1.add(“radiobutton”, undefined, undefined, {name: “radiobutton2”});
      radiobutton2.text = “Width”;

      // GROUP2
      // ======
      var group2 = dialog.add(“group”, undefined, {name: “group2”});
      group2.orientation = “row”;
      group2.alignChildren = [“left”,”center”];
      group2.spacing = 10;
      group2.margins = 0;

      var edittext1 = group2.add(‘edittext {properties: {name: “edittext1”}}’);
      edittext1.text = “Enter the width or height to set”;

      // GROUP3
      // ======
      var group3 = dialog.add(“group”, undefined, {name: “group3”});
      group3.orientation = “row”;
      group3.alignChildren = [“left”,”center”];
      group3.spacing = 10;
      group3.margins = 0;

      var button1 = group3.add(“button”, undefined, undefined, {name: “button1”});
      button1.text = “OK”;

      var button2 = group3.add(“button”, undefined, undefined, {name: “button2”});
      button2.text = “Cancel”;

      dialog.show();

    • #1240448

      Brian Pifer – this is lovely :)

      I will give this a go. Thank you so much.

    • #1240458
      David Blatner
      Keymaster

      That looks neat! But Brian, just to confirm: that’s only the UI, right? The dialog box? It doesn’t actually change anything in the document?

    • #1240708
      Brian Pifer
      Participant

      Correct, just something to started on the UI. From there, it would be a matter of resizing the rectangles and their containing images.

      app.selection returns an array of all the selected objects on a page. If you select a frame with your black arrow tool, that’s a rectangle object. With one object selected:

      var rect = app.selection[0];
      var containingImage = rect.graphics[0];

      You can look at the rect.geometricBounds property, as well as rect.resize() and rect.fit() methods. Lots of different ways to skin the cat based on your ultimate needs and how your doc is set up.

      For some guidance on the Rectangle object, https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Rectangle.html

Viewing 8 reply threads
  • You must be logged in to reply to this topic.
Forum Ads