2

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:

before

After:

after

Is it possible?

4
  • How would it work? Two images with different aspects can not be easily normalized, so would you: Normalize by height, ignoring aspect ratio? By width? Length of circumference? By bounding circle? By height and width (ignoring aspect ratio)? By BB area? Shape area?
    – joojaa
    Commented Jan 29, 2017 at 11:42
  • I keep ratio and resize by height Commented Jan 29, 2017 at 12:38
  • And I set that I want to all path have 100point height but width keep aspect ratio. Also I can set ll of path to position x:0 y: 0 Commented Jan 29, 2017 at 12:47
  • 1
    ok that's just not my idea of normalization. But fine.
    – joojaa
    Commented Jan 29, 2017 at 13:27

1 Answer 1

2

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:

scaled to fit by height

Image 1: Objects on first row are scaled to fit by height on second row.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.