Skip to main content
Inspiring
June 14, 2018
Answered

Scale all images at once in InDesign

  • June 14, 2018
  • 2 replies
  • 28204 views

Hi,

I am working on a document with 500 images and all of them run beyond the text frame size. Hence, to fit them to the frame, I tried to use Transform->Scale and set the percentage value to less than 100% and the image got fit into the text frame. However, the problem is with a single selection. Selecting an image every time and setting the scale for 500 objects is a time consuming task. (Kindly note that all images are inline hence, I cannot use ScaleGraphics to resize them all at once).

I tried using Object style but it does not incorporate Scale option in its palette. I tried using Find/Change option but it does not take anything other than an Object style, hence bringing me back to square one. I urge all the InDesign experts to provide their thoughts on the following question related to the problem:

Is it possible to apply Scale option to all the images at once - a script or plugin or simple technique?

Any guidance in the right direction would be greatly appreciated. Hope to receive a positive response.

Regards,

Aman Mittal

This topic has been closed for replies.
Correct answer vinny38

amanm5143  wrote

2. I had set the Auto-sizing Option in the Text Frame Options to "Width and Height"

[...]

Though the script worked but it cropped the right side part of the image to fit to the width and bottom part to fit to the height. Basically, it trimmed the images to fit to the size of text frame.

Well, I actually meant Object style > Fitting options, not Text Frame Options > Auto-sizing.

This is why your images got cropped.

Now, thinking about it, maybe auto-fitting is not what you want...

So, lets think differently. Instead of resizing the frame, let's rescale it.

Give this version 2 script a try and tell me if it works for you.

Besides, I modified it because not everyone works in millimeters... It now should work whatever measurement units are in use.

I also "wrapped" it, so you can CTRL-Z it now...

//FitAnchorToColumn v2

//Transform anchored objects in order to rescale them to make them fit column width, keeping proportions.

//by Vinny

if (parseFloat(app.version) < 6)

    main();

else

    app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "FitAnchorToColumn");

function main() {

    if (app.documents.length > 0) {

        var

        myDoc = app.activeDocument,

        docUnits = myDoc.viewPreferences.horizontalMeasurementUnits;

        app.findGrepPreferences = app.changeGrepPreferences = null;

        app.findGrepPreferences.findWhat = "~a"

        var myFound = myDoc.findGrep();

        for (i = 0; i < myFound.length; i++) {

            if (typeof myFound.parentTextFrames[0] != "undefined") {

                var columnWidth = myFound.parentTextFrames[0].textFramePreferences.textColumnFixedWidth,

                myObjectWidth = myFound.pageItems[0].geometricBounds[3]-myFound.pageItems[0].geometricBounds[1],

                myScaleFactor = columnWidth/myObjectWidth,

                myScaleMatrix = app.transformationMatrices.add({horizontalScaleFactor:myScaleFactor,verticalScaleFactor:myScaleFactor});

                

                myFound.pageItems[0].transform(

                    CoordinateSpaces.INNER_COORDINATES,

                    AnchorPoint.TOP_LEFT_ANCHOR,

                    myScaleMatrix

                );

            }

        }

        app.findGrepPreferences = app.changeGrepPreferences = null;

    } else {

        alert("Open a document");

    }

}

amanm5143  wrote

Additionally, it didn't run on every text frame; I had to select each text frame and run the script again to make the desired changes.

Hmmmm... that's strange. I don't know what to tell you. It should affect the whole document...

Let's see if version 2 magically solves it ^^

2 replies

vinny38
Legend
June 14, 2018

Hi.

Interesting question.

Could you give this script a try and report back?

//FitAnchorToColumn v1

//Fit anchored objects to column width keeping proportions

//by Vinny

if (app.documents.length > 0) {

    var myDoc = app.activeDocument;

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.findWhat = "~a"

    var myFound = myDoc.findGrep();

    for (i = 0; i < myFound.length; i++) {

        if (typeof myFound.parentTextFrames[0] != "undefined") {

            var columnWidth = myFound.parentTextFrames[0].textFramePreferences.textColumnFixedWidth;

            myFound.pageItems[0].resize(

                CoordinateSpaces.INNER_COORDINATES,

                AnchorPoint.TOP_LEFT_ANCHOR,

                ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, [UnitValue(columnWidth + 'mm').as('pt'), ResizeConstraints.KEEP_CURRENT_PROPORTIONS]

            );

        }

    }

} else {

    alert("Open a document");

}

Script detect column width for a anchored object, then resize it.

Text will then reflow, so make sure you have consistent number of columns and column width (using primary text frames?), otherwise reflow could mess the whole thing.

Edit:

Oh I forgot to say that script only resizes the anchored object itself, not the imported graphic.

In my example, I used an Object style for my pics, with auto-resize ON

amanm5143Author
Inspiring
June 14, 2018

Hi Vinny,

Thank you for taking out the time to find a solution and work upon the same. I tried your solution following these conditions:

1. All the images were anchored

2. I had set the Auto-sizing Option in the Text Frame Options to "Width and Height"

3. Anchor Position was not changed.

4. Column width and numbers were of fixed number - 1

Though the script worked but it cropped the right side part of the image to fit to the width and bottom part to fit to the height. Basically, it trimmed the images to fit to the size of text frame. Additionally, it didn't run on every text frame; I had to select each text frame and run the script again to make the desired changes.

I think my problem would get resolved if I am able to use the Transform tool to change the percentage value from 100% for all images, BUT, at a single go.

I appreciate your hard work and am grateful to you for trying things out. I hope The report contained all the necessary info. Looking forward to your reply.

Regards,

Aman Mittal

amanm5143Author
Inspiring
June 18, 2018

Hi Aman,

in priciple that would mean:

1. Open the story in the Story Editor Window.

2. Cut the character that constitutes the anchored image and paste it to the first insertion point of a different text frame whose dimensions will allow to see the full image. Maybe you'll need a gigantic text frame ( who knows? ).

3. Resize the image

4. Cut and paste the character that constitutes the resized image back to the Story Editor.

With a script it's (nearly) the same.

To change dimensions you must move the image out of it's original story.

Fact is: When in overset you cannot tell its dimensions.

In case your pasteboard cannot hold it's dimensions, image's too large, you have to change pasteboard dimensions of the document or you move it to a new document where the pasteboard can hold it.

Regards,
Uwe


Hey Uwe,

This is true and I follow these two approached only. Either I follow Transform Tool or I cut paste image in a new document and rescale it to bring it back to the original document. You are absolutely right that in over set, one cannot tell the dimensions. That is the reason, I spoke about custom positioning as it helps in getting rid of the over set text problem as a temporary fix. This way, I don't have to cut paste the image to another frame. I just go through the same document, select the image frame I want to re-scale and use the Transform Tool, then and there. In such a way, without changing the pasteboard dimensions of the document, you are able to fit the image to the frame.

It is just that when you are working with a batch of 500 images or so, working on each one of them become a time consuming task and a script helps you in saving that time.

Hence, I thought of consulting with the experts.

Regards,

Aman

Colin Flashman
Community Expert
Community Expert
June 14, 2018

Have you tried this script from in-tools?

Scale Graphics Script | in-tools.com

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
amanm5143Author
Inspiring
June 14, 2018

Hi Colin,

Thank you for taking out the time and replying to the discussion. As mentioned earlier, I had tried ScaleGraphics script. However, the script does not work for inline images (anchored images); it only works on unachored ones.

Regards,

Aman Mittal