Copy link to clipboard
Copied
DEAL ALL,
GREETINGS!
I'm facing a small problem. There is aproject i'm developing script for. Anyhow, the designers asked me somthing and since I'm not a designr, so I don't have a clue how to do it from the UI so i can understand how to do it wit script.
So, they asked me to decrese the size of image to make it 30% because the current size is 50%. It's applicable with code? i dont even changed the size of image! i Just place the image and use the fit functons to make it smaller and better, check my code, below:
var doc = app.documents.add()
var image = File.openDialog("Please try to select the icons folder");
var rect1 = doc.pages[0].textFrames.add({
geometricBounds: [12.7, 12.7, 90, 90]
});
rect1.place(image)
rect1.fit(FitOptions.PROPORTIONALLY)
rect1.fit(FitOptions.FRAME_TO_CONTENT)
app.activeWindow.viewDisplaySetting = ViewDisplaySettings.HIGH_QUALITY;
However, is it possiable to decrease the image size by percentege? and how?
I'm using JS.
Thanks all.
I think it's enough to change frame size.
90 - 12.7 = 77.3
but it's only 50℅ ...
ok! 77.3 * 2 = 154.6
we need 30℅, i.e.
154.6 * 30 / 100 = 46.38 + 12.7 = 59.08
and now we can write:
geometricBounds: [12.7, 12.7, 59.08, 59.08]
You can try this below sample script:
var doc = app.documents.add();
var image = File.openDialog("Please try to select the icons folder");
var rect1 = doc.pages[0].textFrames.add({
geometricBounds: [12.7, 12.7, 90, 90]
});
rect1.place(image);
rect1.fit(FitOptions.PROPORTIONALLY);
rect1.fit(FitOptions.FRAME_TO_CONTENT);
rect1.graphics[0].absoluteHorizontalScale = 30;
rect1.graphics[0].absoluteVerticalScale = 30;
rect1.fit(FitOptions.FRAME_TO_CONTENT);
app.activeWindow.viewDisplaySetting = Vi
...
Copy link to clipboard
Copied
You can reduce the page size by a percentage, manually, in the Adjust Layout feature.
Copy link to clipboard
Copied
Have a look at https://www.indiscripts.com/post/2018/06/coordinate-spaces-and-transformations-5 - download link at the bottom.
Copy link to clipboard
Copied
Thanks!
Copy link to clipboard
Copied
You can scale either the image or its parent frame using the absoluteHorizontalScale and absoluteVerticalScale properties. This scales the image.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Image.html
var doc = app.documents.add()
doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
var image = File.openDialog("Please try to select the icons folder");
var rect1 = doc.pages[0].rectangles.add({geometricBounds: [12.7, 12.7, 90, 90]});
rect1.place(image);
rect1.images[0].absoluteHorizontalScale = 30;
rect1.images[0].absoluteVerticalScale = 30;
app.activeWindow.viewDisplaySetting = ViewDisplaySettings.HIGH_QUALITY;
Copy link to clipboard
Copied
Thanks for sharing with me your work, I've tried it, but since we have many images so the size will vary, so some image worked and the others alert me that the value "30" would cause one or more object to leave the pasteborder. Anyhow, thanks for you time and suport.
Copy link to clipboard
Copied
I think it's enough to change frame size.
90 - 12.7 = 77.3
but it's only 50℅ ...
ok! 77.3 * 2 = 154.6
we need 30℅, i.e.
154.6 * 30 / 100 = 46.38 + 12.7 = 59.08
and now we can write:
geometricBounds: [12.7, 12.7, 59.08, 59.08]
Copy link to clipboard
Copied
Thanks! The calcultion, worked fine and decresed the size of image, because i changed the frame size. Thanks so much
Copy link to clipboard
Copied
I think you have to consider the actual dimensions of the placed image, and if you want to keep the bounds of the .rect1 frame unchanged.
For example here are two cases: on the left the image’s actual dimensions are 18" x 24", and when it is scaled by 30% centered, it fits in the frame. The version on the right has a starting image dimension of 5" x 7", and when it is scaled by 30% it is smaller than the frame—in this case you could fit the frame to the image, but that would change the bounds of the original rectangle.
To place centered you can set the transform reference point with this:
app.layoutWindows[0].transformReferencePoint = AnchorPoint.CENTER_ANCHOR;
Copy link to clipboard
Copied
You can try this below sample script:
var doc = app.documents.add();
var image = File.openDialog("Please try to select the icons folder");
var rect1 = doc.pages[0].textFrames.add({
geometricBounds: [12.7, 12.7, 90, 90]
});
rect1.place(image);
rect1.fit(FitOptions.PROPORTIONALLY);
rect1.fit(FitOptions.FRAME_TO_CONTENT);
rect1.graphics[0].absoluteHorizontalScale = 30;
rect1.graphics[0].absoluteVerticalScale = 30;
rect1.fit(FitOptions.FRAME_TO_CONTENT);
app.activeWindow.viewDisplaySetting = ViewDisplaySettings.HIGH_QUALITY;
Best
Sunil
Copy link to clipboard
Copied
THANKS!!! IT WORKED PERFICTILYY
Find more inspiration, events, and resources on the new Adobe Community
Explore Now