Skip to content

Instantly share code, notes, and snippets.

@jsbueno
Created June 26, 2020 21:03
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 jsbueno/d51df9ef1c0dc3a3fbb47ba31714685b to your computer and use it in GitHub Desktop.
Save jsbueno/d51df9ef1c0dc3a3fbb47ba31714685b to your computer and use it in GitHub Desktop.
GIMP 2.10 plugin: redimensiona camada selecionada para tamanho da primeira camada
#!/usr/bin/env python2
# coding: utf-8
from gimpfu import *
def autoresize(img, drw):
pdb.gimp_image_undo_group_start(img)
try:
new_width = base_width = img.layers[-1].width
new_height = base_height = img.layers[-1].height
if drw.width / base_width > drw.height / base_height:
new_height = int(drw.height / (drw.width / base_width))
else:
new_width = int(drw.width / (drw.height / base_height))
pdb.gimp_layer_scale(drw, new_width, new_height, True)
finally:
pdb.gimp_image_undo_group_end(img)
register(
"autoresize",
"autoresize",
"autoresize - autoresize current layer to fit in first image layer",
"Joao S. O. Bueno",
"Joao S. O. Bueno",
"2020. GPL applies.",
"Resample Layer to Base Layer Size",
"*",
[(PF_IMAGE, "Image", "Image", None), (PF_DRAWABLE, "Drawable", "Drawable", None), ],
[],
autoresize,
menu="<Image>/Edit")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment