Batch resize longest sides of selected elements (resize to fit)

How can I batch resize the longest sides of the elements I have selected? In other words, how can I batch resize to fit into a frame with a specific size?

I have a lot of vectors. They are all in different sizes, and I want to resize them to fit into a 20x20px frame. It is easy to batch resize all the vectors so that they all have a 20px width or a 20px height. But I want them to be 20px on their longest side, which for some vectors is the width and for others the height.

I haven’t been able to find any Figma functions or plugins that allow me to do this. My current solution is this:

  1. Select parent frames
  2. Plugins > Automater > Object > Add Autolayout to each
  3. Set AL alignment to center
  4. Set height & width to fixed, 20px
  5. Select vectors (Enter)
  6. Plugins > Automater > Resize > Scale to fit to parent
  7. Select parent frames (Shift+Enter)
  8. Set height & width to 24px
  9. Plugins > Remove Autolayout Faster

I use Autolayout because I want the vectors to be centered inside the 20x20px frame (AFAIK there is no way to batch Align the vectors inside their parent frames), which does not happen automatically when using the Automater plugin’s Resize to Fit option. I have to remove Autolayout again in the last step because otherwise the vectors will not scale along with the frame when I resize the frame later. Unfortunately, removing Autolayout with Remove Autolayout Faster takes a very long time for the hundreds of frames I have. Disable Autolayout is faster but it doesn’t work on components, and my frames are components.

Does anyone have a better/faster way to do this?

It seems like the Icon Resizer plugin might do exactly this!

image

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.