Skip to content

Instantly share code, notes, and snippets.

@kemiljk
Last active March 14, 2021 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kemiljk/f48fc6b5cf549e5103eaa1abd34eb5df to your computer and use it in GitHub Desktop.
Save kemiljk/f48fc6b5cf549e5103eaa1abd34eb5df to your computer and use it in GitHub Desktop.
A way to crop all images to the same aspect
// Note: this uses the Scripter API so won't work via regular Figma plugin code
// Download here: https://www.figma.com/community/plugin/757836922707087381/Scripter
const layers = figma.currentPage.findAll(isImage);
figma.currentPage.selection = layers
for (let shape of await find(selection(), n => isImage(n) && n)) {
// Update image paints to use "FILL" scale mode
shape.fills = shape.fills.map(p =>
isImage(p) ? {...p, scaleMode: "FILL",} : p)
shape.resize(375, 375)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment