Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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