Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Script to resize an image and move to specific spot

Explorer ,
Jun 26, 2021 Jun 26, 2021

Copy link to clipboard

Copied

I have a lot of jobs where I need to have the specific size image at the top of an A4 page with 3mm bleed.

 

Just wondering if it's possible to have a script that i can execute with an image selected on the page and it sizes it to 216mm width, 116.522mm height, and set the Y coordinate to 55.261mm. Also if it could centre the image horizontally to the page that would be great also (don't think this can be done with the x coordinate because it might change depending if its a pages vs spreads layout?).

 

Any help with this would be greatly appreciated, thanks! 

 

Example:

danielw42205661_1-1624770278321.png

 

 

TOPICS
Scripting

Views

306

Likes

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 2 Correct answers

Adobe Community Professional , Jun 27, 2021 Jun 27, 2021
You can set the size and position in the object styles. Just apply the object style to the image you want. Window>Styles>Object Styles And scroll down the menu on the left

Likes

Translate

Translate
Adobe Community Professional , Jun 27, 2021 Jun 27, 2021
Select the image frame: var y = 55.261; var h = 116.522; var w = 216; app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS; var pw = app.documents.item(0).documentPreferences.pageWidth; app.documents.item(0).selection[0].geometricBounds = [y, pw-w, y + h, w]; app.documents.item(0).selection[0].fit(FitOptions.PROPORTIONALLY);

Likes

Translate

Translate
Explorer ,
Jun 26, 2021 Jun 26, 2021

Copy link to clipboard

Copied

Sorry forgot to mention, if it could fill frame proportionally after the resize that would be great too. 

Likes

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
Adobe Community Professional ,
Jun 27, 2021 Jun 27, 2021

Copy link to clipboard

Copied

You can set the size and position in the object styles.

 

Just apply the object style to the image you want.

Window>Styles>Object Styles

EugeneTyson_0-1624781861124.png

 

And scroll down the menu on the left

EugeneTyson_1-1624781886003.png

 

 

Likes

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
Adobe Community Professional ,
Jun 27, 2021 Jun 27, 2021

Copy link to clipboard

Copied

 

 

Select the image frame:

 

var y = 55.261; var h = 116.522; var w = 216;

app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS;
var pw = app.documents.item(0).documentPreferences.pageWidth;
app.documents.item(0).selection[0].geometricBounds = [y, pw-w, y + h, w];
app.documents.item(0).selection[0].fit(FitOptions.PROPORTIONALLY);

 

 

 

Likes

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
Adobe Community Professional ,
Jun 27, 2021 Jun 27, 2021

Copy link to clipboard

Copied

That's fantastic.

 

Just wondering if the style route is better as you could tweak the position and all would update.

 

Does the script do that?

Likes

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
Adobe Community Professional ,
Jun 27, 2021 Jun 27, 2021

Copy link to clipboard

Copied

I don’t think you can set a specific x or y position with a style unless the image is anchored in a text flow?

Likes

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
Adobe Community Professional ,
Jun 27, 2021 Jun 27, 2021

Copy link to clipboard

Copied

I think it does work. I will have to try tomorrow

Likes

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
Adobe Community Professional ,
Jun 27, 2021 Jun 27, 2021

Copy link to clipboard

Copied

Yes, you’re right. I forget about the size and position option, which got added a few versions back, and which I obviously never use.

Likes

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 ,
Jun 27, 2021 Jun 27, 2021

Copy link to clipboard

Copied

Thanks Rob. Although it does size and fit the frame correctly, it doesn't move it to the top of the page for me. Did you test it and it worked for you? I'm on CC 2019 so not sure if that's a factor for it not working. 

Likes

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 ,
Jun 27, 2021 Jun 27, 2021

Copy link to clipboard

Copied

LATEST

Nevermind, figure out i had to set Y to -3. Then it puts it in the right spot. Thanks Rob!!!

Likes

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