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

Images scaling while placing using script

New Here ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Hi all, I am noticing a strange behavior of .place on scaling while placing images using script. Below is the code snippet:

 

with(app.activeDocument.stories[0].paragraphs[0].insertionPoints[-1]) {
place(File(myImage));
//place(File(myImage), false, {horizontalScale: 100, verticalScale: 100});
}

 

The first place command is showing my sample image scaled at 111.5% while the container box itself is created of correct size (original image size).

 

When I run the second place command with horizontal and vertical scales set to 100% then only it comes okay.

 

Different scaling is being applied to different images but I am not able to see any scaling applied in the original images themselves. I have attached the sample image as well to this thread.

 

Hope it must be an easy thing to solve. Can someone please help me understanding this strange behaviour of InDesign?

 

Best wishes,

Nishant

TOPICS
Scripting

Views

374

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 , Jul 28, 2021 Jul 28, 2021

Hi,

 

Just to get the easy stuff out of the way, in Preferences->General there is this setting, might want to make sure it is off.

 

BarlaeDC_0-1627459917797.png

 

Votes

Translate

Translate
Community Expert ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Hi,

 

Just to get the easy stuff out of the way, in Preferences->General there is this setting, might want to make sure it is off.

 

BarlaeDC_0-1627459917797.png

 

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Hi Barlae, if I may call you so. That's just perfect and solved the problem. Thank you so much to you and to this lively community to allow newbies like me to clarify such basic things.

 

I read through Adobe's documentation and it says "Content-Aware Fit removes the transformations, such as Scale, Rotate, Flip, or Shear, applied to the image. However, the transformations applied to the frame are not removed.".

But the result we get is otherwise, i.e. it applies transformations such as scale even though they are not applied in the image itself.

 

Although I am curious to know why content aware fit artifically scale the images, it is fine if you are not able to answer my this question due to other priorities.

 

Regards,

Nishant

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Hi Nishant, if you are writing a script for inserting the image, try something like this:

 

var myImagePath = '/Users/mark/Desktop/sample.png';
var lastInsertionPointOfStory = app.activeDocument.stories[0].paragraphs[0].insertionPoints[-1];
var img = (lastInsertionPointOfStory.place(File(myImagePath)))[0];
img.horizontalScale = 50;
img.verticalScale = 50;
img.fit(FitOptions.FRAME_TO_CONTENT);

 

Notice that you have more control over the placed image, including applying the FitOption we want.

 

Also, if you don't mind, I recommend you do not use the "with" form in this case—it implies you are going to be doing a lot of things to the last insertion point, but that isn't the case in your snippet, and it makes it awkward in my opinion.

- 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
New Here ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Thanks Mark, it makes sense.

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Hi,

 

I don't have a full answer, I do know that "Content aware fit" using AI to try and work out what the user actually wants to be shown in the frame, this means it does what it thinks is best to get what it considers to be the content of the image to be front and centre in the frame.

My guess is it does that by applying its on Scale, rotate, flip or shear, but that is just a guess.

 

Happy it helped.

 

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

LATEST

Hi Nishant,

not the case here, but also note:

 

A possible issue with the first method where you are placing an image to an insertion point:

The text frame of that insertion point could be scaled.

And that would scale the placed image as well.

 

Symptom of a scaled text frame:

Select it and look up the values for x and y in the scaling editing fields.

They are different from 100%.

 

If you are not aware of it, check the preferences before transforming an object.

app.transformPreferences.whenScaling

and others at app.transformPreferences:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TransformPreference.html

 

Regards,
Uwe Laubender

( ACP )

 

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