Highlighted

how to resize text frame to be fit with the image using script?

Participant ,
Aug 20, 2020

Copy link to clipboard

Copied

Hey everone,

 

I'm creating a textframe with a spicfic sizes, after that i use place function and place an images. and also i'm using fitting function. Anyhow, sometimes the images become smaller than the frame that i already have made. Are there any way with coding can help me to resize the frame to be fit to the image??

 

this is the code. 

var rect = doc.pages[pageIdx].textFrames.add({
										geometricBounds: arrayOfSize[12.7, 12.7, 90, 90]
									});
									
									rect.place(image)
									rect.fit(FitOptions.PROPORTIONALLY)

						

 

Thamks all! 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Did you try using other fitting options? See the list at the following link

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

If you want that in the case when the image is smaller than the frame, you don't need to do anything/do something different. You can calculate the height/width of the image from its geometricbounds and compare that with the height/width of the frame to make a decision.

-Manan

TOPICS
Activation billing and install, Bug, EPUB, Feature request, How to, Import and export, InCopy workflow, Performance, Print, Publish online, Scripting, SDK, Server developers, Sync and storage, Type

Views

93

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

how to resize text frame to be fit with the image using script?

Participant ,
Aug 20, 2020

Copy link to clipboard

Copied

Hey everone,

 

I'm creating a textframe with a spicfic sizes, after that i use place function and place an images. and also i'm using fitting function. Anyhow, sometimes the images become smaller than the frame that i already have made. Are there any way with coding can help me to resize the frame to be fit to the image??

 

this is the code. 

var rect = doc.pages[pageIdx].textFrames.add({
										geometricBounds: arrayOfSize[12.7, 12.7, 90, 90]
									});
									
									rect.place(image)
									rect.fit(FitOptions.PROPORTIONALLY)

						

 

Thamks all! 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Did you try using other fitting options? See the list at the following link

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

If you want that in the case when the image is smaller than the frame, you don't need to do anything/do something different. You can calculate the height/width of the image from its geometricbounds and compare that with the height/width of the frame to make a decision.

-Manan

TOPICS
Activation billing and install, Bug, EPUB, Feature request, How to, Import and export, InCopy workflow, Performance, Print, Publish online, Scripting, SDK, Server developers, Sync and storage, Type

Views

94

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
Aug 20, 2020 0
Adobe Community Professional ,
Aug 20, 2020

Copy link to clipboard

Copied

Did you try using other fitting options? See the list at the following link

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

If you want that in the case when the image is smaller than the frame, you don't need to do anything/do something different. You can calculate the height/width of the image from its geometricbounds and compare that with the height/width of the frame to make a decision.

-Manan

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
Reply
Loading...
Aug 20, 2020 2
Participant ,
Aug 20, 2020

Copy link to clipboard

Copied

Thanks! the sheet was very helpfull

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
Reply
Loading...
Aug 20, 2020 0
Adobe Community Professional ,
Aug 20, 2020

Copy link to clipboard

Copied

Hi,

Try using 

FitOptions.CONTENT_TO_FRAME

instead of 

FitOptions.PROPORTIONALLY

 

Difference

FitOptions.CONTENT_TO_FRAME

Resizes content to fit the frame. Note: Content that is a different size than the frame appears stretched or squeezed.

 

FitOptions.PROPORTIONALLY

Resizes content to fit the frame while preserving content proportions. If the content and frame have different proportions, some empty space appears in the frame.

 

For more description about Fitting Options, read following link

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

Best regards

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
Reply
Loading...
Aug 20, 2020 0
Participant ,
Aug 20, 2020

Copy link to clipboard

Copied

Hey! thanks for sharing, I've tried and it worked!

 

I've other question. It's possiable to place an image without a text frame? if yes how can u specyfy the maseurments or were specify where to postion the image.

 

THANKS again.

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
Reply
Loading...
Aug 20, 2020 0
Adobe Community Professional ,
Aug 20, 2020

Copy link to clipboard

Copied

There is a place method on number of objects like spread, page etc. Refer the DOM to find the object appropriate for you. In the place method you can speficy things like the point where to place, layer etc. See the following

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

-Manan

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
Reply
Loading...
Aug 20, 2020 0
Adobe Community Professional ,
Aug 20, 2020

Copy link to clipboard

Copied

One thing to note about your sample code; you are creating a text frame, and placing the image in the frame and not the text flow, which would convert the text frame to a graphic type frame.

 

You could also place the image at an insertion point in the text frame’s text flow, and in that case the frame would remain a text frame, and the image would be anchored in the text. All images have a parent frame, so if you place the image in the text flow there would also be a parent frame holding the image. If you place the image directly on the page, its parent frame will have the same bounds—the image will be placed fit to the parent frame.

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
Reply
Loading...
Aug 20, 2020 0
Participant ,
Aug 22, 2020

Copy link to clipboard

Copied

Thanks rob for the explanition, could you show me how to do it? 

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
Reply
Loading...
Aug 22, 2020 0
rob day LATEST
Adobe Community Professional ,
Aug 27, 2020

Copy link to clipboard

Copied

—Sorry I’m having notification problems and didn’t see your last post.

 

This places an image and its container frame directly on the page:

 

 

//the active page
var p = app.activeWindow.activePage

//place an image on the page and get its container frame 
var img = p.place(File("...pathto/image.psd"));
var imgFrame = img[0].parent;

//change the bounds of the image’s frame and fit proportionally
imgFrame.geometricBounds = [12.7, 12.7, 90, 90];
img[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
Reply
Loading...
Aug 27, 2020 0