0

I am a veteran ID user here, but still pretty green on scripting. I had taken a JS class once about three years ago, but it's one of those use-it-or-lose-it things, I think. I don't remember much, but I remember enough to read the code and see if it would work for me.

Currently, I'm working on a 250-300 page document. About 1/2 of those pages have an image on it that is oversized for the page. I would like to have a script that will allow me to select the pages that I want to work with (From page to page), scale the image proportionally (either by percentage, dimensions in inches, or by entering one value - height or width and allowing the secondary value to adjust proportionally. Additionally, it is the image itself that I want to resize - the frame needs to adjust proportionally to the graphic.

Lastly, I want to rotate the image 90º counterclockwise and then center vertically and horizontally to the page margins.

I have scoured the internet for a similar code - even one that I could modify to fit my needs but each time I've tried to modify something, I've managed to break it. So, I'll let it to the code gurus, and I'll stick with my page layout skills. 🙂

So, to recap, I need a script that will:

  1. Choose the specific range of pages (From page XX to page XX) that I need to adjust.
  2. Scale the images to a specific percentage or dimension (inches) and/or enter one value and have the secondary value auto-size proportionally. The frame needs to adjust proportionally to the image.
  3. Rotate images 90° counterclockwise.
  4. Center the images vertically and horizontally to page margins.

Can someone help - pretty please? 😄

Here is a link to a script that I've used with success to scale the images but it does not have a rotate and center to margins feature. https://drive.google.com/file/d/1wGE7IBHtGlYh_N0PqgtOcTE56Qf92pfk/view?usp=sharing

Here are screenshots showing exactly what I want to do:

enter image description here

I have tried modifying a few existing scripts but my coding is so rusty, I could not make anything work. I need some assistance with writing a good script to accomplish my task at hand. :)

3
  • The task looks quite doable. Probably I can add a couple checkboxes into the existing scripts. Or it can be a separate script to rotate and center images. Commented Oct 12, 2023 at 9:24
  • Unfortunately the existing script has so-called binary format (jsxbin). It cannot be modified. Let me know if you want the second option (a script to rotate and center images). Commented Oct 13, 2023 at 14:26
  • It looks like the guy already got the answer here: community.adobe.com/t5/indesign-discussions/… (and doesn't even thanked the expert). Downvote and vote to close. Commented Oct 14, 2023 at 11:07

1 Answer 1

0

You can rotate an object applying css from javascript.

 function rotate(deg){
 var div = document.getElementById("img");
 div.style.webkitTransform ='rotate('+deg+'deg)'; 
 div.style.mozTransform ='rotate('+deg+'deg)'; 
 div.style.msTransform ='rotate('+deg+'deg)'; 
 div.style.oTransform ='rotate('+deg+'deg)'; 
 div.style.transform ='rotate('+deg+'deg)';
 }
<div style="background:#ff00ff;width:70px;height:70px;" id="img">ROTATE 90 DEG</div><br/>
   <input type="range" min="1" max="90" step="1" oninput="rotate(this.value);">

Sign up to request clarification or add additional context in comments.

1 Comment

Alas. It doesn't work in InDesign this way. InDesign != Web browser. They are very different beasts. Even if Extendscript looks much like the ancient version of Javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.