• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Resizing an anchored object (using Object Styles) without changing the size of the content

Explorer ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

Hello ... I would love some help with this.

 

I have 300 or so headshots cropped the way I want them, anchored in text boxes so that they reflow.

What I want to do is change the size of the image box (which is consistent throughout), for another use, and then extract the images (using a script). This has worked in the past!

 

The image boxes (within the text box) are an Object Style. So I change the size of the image box in the Object Style (adding width).  BUT ... the image changes size too! It basically increases the width to the new width and now all the heads are cut off at the top. I have tried changing the Fitting options, but nothing seems to work. I have a feeling that I over-rode a "fit image proportionally to box" script when I resized the images to my liking, and so when I say "none" in the auto-fit box, it undoes my over-ride. It's pretty clear that I don't understand what's happening.

 

Thanks for any help with this!

Alison

 

 

TOPICS
How to , Scripting

Views

242

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 15, 2021 Aug 15, 2021

Hi @alisonl0shi, I'm not sure of your exact situation, but I've written a script that adjusts the size of the frames of graphics and I think should ignore the Object Style you've set. Of course you must remove the width and height from your object style first. To give it a try:

1. Set the values for "adjust" and "move" variables as you need and save script.

2. Select a textframe in your document that contains the story that contains the graphics (any text frame in chain will do), or put insertion

...

Votes

Translate

Translate
Explorer ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

By the way, when I apply the new, desired width to each image box within the text box, ***without*** using the Object Styles, it works fine. It's just that I don't want to do that 300 + times ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2021 Aug 15, 2021

Copy link to clipboard

Copied

Hi @alisonl0shi, I'm not sure of your exact situation, but I've written a script that adjusts the size of the frames of graphics and I think should ignore the Object Style you've set. Of course you must remove the width and height from your object style first. To give it a try:

1. Set the values for "adjust" and "move" variables as you need and save script.

2. Select a textframe in your document that contains the story that contains the graphics (any text frame in chain will do), or put insertion point in the story.

3. Run script.

/* by m1b, here https://community.adobe.com/t5/indesign/resizing-an-anchored-object-using-object-styles-without-changing-the-size-of-the-content/m-p/12316397*/

function main() {

    // this example will
    // (a) expand the graphic's container by 10mm leftwards, and
    // (b) move the graphic (inside the container) upwards by 5mm


    var mm = 2.83465,
        inch = 72,

        // enter your adjustment and movement values here:

        /* adjust frame */
        adjustment = {
            top: 0,
            left: -10 * mm,
            bottom: 0,
            right: 0
        },

        /* move */
        movement = {
            x: 0,
            y: -5 * mm
        }


    // eg. start with a textFrame selection,
    // then get all the graphics in the textFrame's
    // parent story. you can get an array of graphics
    // anyhow you like
    var story = app.activeDocument.selection[0].parentStory,
        graphics = story.allGraphics;

    // plug your graphics array into this function call
    adjustGraphicsAndContainers(graphics);

    // this is the function
    function adjustGraphicsAndContainers(graphics) {
        app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

        // adjust each graphic/container
        for (var i = 0; i < graphics.length; i++) {
            adjust(graphics[i], adjustment, movement)
        }

        function adjust(graphic, adjust, move) {
            // modified each element of items bounds
            // by the values in changeInPts argument
            var container = graphic.parent,
                graphic = container.graphics[0],
                cb = container.geometricBounds,
                gb = graphic.geometricBounds,
                adjust = adjust || { top: 0, left: 0, bottom: 0, right: 0 },
                move = move || { x: 0, y: 0 },

                // container bounds, adjusted
                newContainerBounds = [
                    /* T */ cb[0] + adjust.top,
                    /* L */ cb[1] + adjust.left,
                    /* B */ cb[2] + adjust.bottom,
                    /* R */ cb[3] + adjust.right
                ],

                // graphic bounds, moved
                newGraphicBounds = [
                    /* T */ gb[0] + move.y,
                    /* L */ gb[1] + move.x,
                    /* B */ gb[2] + move.y,
                    /* R */ gb[3] + move.x
                ];
            //apply the new bounds
            container.geometricBounds = newContainerBounds;
            graphic.geometricBounds = newGraphicBounds;
        }

    }

} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Adjust Graphics And Containers");

 There are many factors that may cause it to fail, so let me know if it doesn't work. Or if you know how to script, feel free to adjust to your specific needs.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 04, 2021 Sep 04, 2021

Copy link to clipboard

Copied

LATEST

Hi M1b, Wow, thank you so much for this! I don't know how to script, but I see what you are doing here (I think). I will try it and see how it goes.

 

I have to admit that the solution I finally ended up using to solve my problem (after MUCH frustration) turned out to be editing the "object style" in *two* steps. In other words, I had to disable the auto sizing, and save that edit. Then I had to go back and edit the style *again* to change the size of the box. But it seems wierd to me that you can't do that all in one step. I should have posted that solution but I was so intent on getting the job done that I forgot to ...

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines