Skip to content

Instantly share code, notes, and snippets.

@Shoeboxam
Created May 7, 2017 23:13
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 Shoeboxam/0bd07267535fe40bc4ffaa683a5e2d58 to your computer and use it in GitHub Desktop.
Save Shoeboxam/0bd07267535fe40bc4ffaa683a5e2d58 to your computer and use it in GitHub Desktop.
Flip an image across diagonal. Uses perspective transform.
#!/usr/bin/env python
from gimpfu import *
def diagonal_flip(image, drawable, downward_diag, upward_diag):
pdb.gimp_image_undo_group_start(image)
if downward_diag:
pdb.gimp_item_transform_perspective(drawable, 0, 0, 0, drawable.height,
drawable.width, 0, drawable.width, drawable.height)
if upward_diag:
pdb.gimp_item_transform_perspective(drawable, drawable.width, drawable.height,
drawable.width, 0, 0, drawable.height, 0, 0)
pdb.gimp_image_undo_group_end(image)
register(
'diagonal_flip',
'Flip layer along diagonal',
'Flip layer along diagonal',
'Michael Shoemate',
'Michael Shoemate',
'2017',
"Diagonal Flip",
"*",
[
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Input drawable", None),
(PF_BOOL, "downard_diag", "Downward Diagonal", 0),
(PF_BOOL, "upward_diag", "Upward Diagonal", 0)
],
[],
diagonal_flip,
menu="<Image>/Filters/Custom")
main()
@Shoeboxam
Copy link
Author

Only works for square images. I could make a new layer with switched dimensions, but I don't actually need it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment