I have quite a few irregular paths (approx. 200), each with a different bounding box. I want scale all of these to a similar size while maintaining their aspect ratio.
Before:
After:
Is it possible?
I have quite a few irregular paths (approx. 200), each with a different bounding box. I want scale all of these to a similar size while maintaining their aspect ratio.
Before:
After:
Is it possible?
Select objects you want to fit by height and run:
#target illustrator
// ScaleToFitVerticalAxis.jsx
//
// Copyright (c) 2017 Janne Ojala
//
// Licence: https://opensource.org/licenses/MIT
visitObjects(app.activeDocument.selection, scaleByHeight, 100)
function scaleByHeight(item, targetHeight){
var factor = targetHeight / item.height;
item.height *= factor;
item.width *= factor;
}
function visitObjects(sel, func, opts) {
for(var i = 0; i < sel.length; i++){
func(sel[i], opts);
}
}
Example:
Image 1: Objects on first row are scaled to fit by height on second row.