Last active
January 28, 2023 10:51
-
-
Save fre-sch/5c8ca933854594a22c37aeb2721e7085 to your computer and use it in GitHub Desktop.
Gimp Python-Fu script that copies selection to new layer and autocrops layer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from gimpfu import * | |
def python_selection_to_layer_cropped(image, drawable, layer_name): | |
pdb.gimp_image_undo_group_start(image) | |
prev_layer = image.active_layer | |
pdb.gimp_edit_copy(image.active_layer) | |
fsel = pdb.gimp_edit_paste(drawable, False) | |
pdb.gimp_floating_sel_to_layer(fsel) | |
image.active_layer.name = layer_name | |
pdb.plug_in_autocrop_layer(image, image.active_layer) | |
image.active_layer = prev_layer | |
pdb.gimp_image_undo_group_end(image) | |
register( | |
"python_fu_selection_to_layer_cropped", | |
"Create new layer from selection and auto crop layer", | |
"Create new layer from selection and auto crop layer", | |
"https://github.com/fre-sch", | |
"https://github.com/fre-sch", | |
"2016", | |
"<Image>/Filters/Selection to Layer (cropped)...", | |
"RGB*, GRAY*", | |
[ | |
(PF_STRING, "layer_name", "Name for new layer", ""), | |
], | |
[], | |
python_selection_to_layer_cropped | |
) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment