• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Resizing images and adding an object style Script

Explorer ,
Aug 23, 2018 Aug 23, 2018

Copy link to clipboard

Copied

After importing a generated XML file in an Indesign file, it automatically looks for all the Links in a specific Map and loads all the highres file i.e. psd, ai etc..

Because every image / illustration has a different size, we made a script that automatically Resizes all Images to the width of the text holder and also Applies an Object Style to the Graphics.

PROBLEM

However when a highres file i.e. psd, ai etc. is too big for the text container, the flow ends in an overset (the red + sign) and the script doesn't work anymore.

QUESTION

Is there a way to make this .jsx script running properly, and/or, Is it even possible to target a hidden image/illustration - beyond overset -with a script?

thank you

TOPICS
Scripting

Views

4.0K

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 23, 2018 Aug 23, 2018

Hi Pelter ,

also see into this thread here:

Scale all images at once in InDesign

Regards,
Uwe

Votes

Translate

Translate
Contributor ,
Aug 23, 2018 Aug 23, 2018

Copy link to clipboard

Copied

hi pelter,

     before importing you have to resize that image manually in paint or any where you want then execute your script.

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 23, 2018 Aug 23, 2018

Copy link to clipboard

Copied

Hi Pelter ,

you can target an anchored graphic or image in overset text.

However, you cannot change the geometric bounds of the container frame.

What you can do is to scale the container frame and its image together by using method transform() on the container frame.

Or: You could first change the anchoredPosition of the container frame to AnchorPosition.ANCHORED. After that you should be able to get geometric bounds of the container frame and calculate the necessary size.

// Text frame selected with overset text due to large images anchored:

var allGraphics = app.selection[0].parentStory.allGraphics;

for(var n=0; n<allGraphics.length; n++)

{

    allGraphics.parent.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED ;

};

Before running the script snippet:

BeforeChangingAnchoredPosition.PNG

After running the snippet:

AfterChangingAnchoredPosition.PNG

Of course it's up to you to change anchoredPosition back to its old value after scaling the container frame.

Regards,
Uwe

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 ,
Aug 23, 2018 Aug 23, 2018

Copy link to clipboard

Copied

Thank U Uwe Laubender,

im happy, will look into it. looks like a solution. Let you know.

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 23, 2018 Aug 23, 2018

Copy link to clipboard

Copied

Hi Pelter,

The query has already been answered by Uwe.

In order to traverse all the images in your text frame you can use the allGraphics property. I suppose you already have the script to resize the images once you get image reference, else Uwe's post has more details on it.

You can get the parent of the image object i.e. the frame holding it within the text frame by using the parent property.

//Suppose that the active selection is the text frame we need to process

var image = app.selection[0].parentStory.allGraphics[0]     //This will give the 1st image if any, you can traverse the allGraphics list

//Demonstrating the scaling of frame that holds the anchored image. a.parent denotes the frame within the text frame that holds the image

image.parent.horizontalScale = 6  

image.parent.verticalScale = 5

//The filePath of the image if needed

var imageFilePath = a.itemLink.filePath

The above code is just for reference purpose with no error checking, i hope it gives you the idea. Let us know if you still have some confusions

-Manan

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 23, 2018 Aug 23, 2018

Copy link to clipboard

Copied

Hi Pelter ,

also see into this thread here:

Scale all images at once in InDesign

Regards,
Uwe

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 ,
Aug 24, 2018 Aug 24, 2018

Copy link to clipboard

Copied

Scale all images at once in InDesign

Script 1 - fixAndDownscaleInlines works perfectly. all the images even the overset images are visible and scaled to 1%, It would be nice if the images would get the width of a column or a text frame. (even better if it had a choice)

Script 2 - function rescaleInlines works great; scales all the images to the width of the text frame but does not target the overset images

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
New Here ,
Sep 19, 2019 Sep 19, 2019

Copy link to clipboard

Copied

LATEST

I made a modification to the script FitAnchorToColumn v8 by vinny38​. A description of the script can be found L on  my website. There is also a video demonstrating working with the apllied object styles and XML examples. The code with examples can be downloaded from Github.

Special emphasis is given to the applied object styles and leaving your changes to the inDesign document intact as you update your document with a modified XML file. The image are placed in a text frame and the image with the caption is placed in a surrounding text frame. You can add an XML width attribute to scale the images to the desired dimensions.

When the script is run after an update of the XML content it checks weather the images already have an object style to determine the newly added images.
You can assign different object styles to the surrounding textframe based on the parent XML tag. I also made an extension to the script for equations made witj LaTeX.

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