Skip to content

Instantly share code, notes, and snippets.

@Shoeboxam
Created May 9, 2017 07:17
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/8ee637b1b2e04c60a1d27f28498f59de to your computer and use it in GitHub Desktop.
Save Shoeboxam/8ee637b1b2e04c60a1d27f28498f59de to your computer and use it in GitHub Desktop.
Gimp: Tile an image to 16x the size via reflections
#!/usr/bin/env python
from gimpfu import *
def reflection_tile(image, drawable):
canvas = gimp.Image(drawable.width * 4, drawable.height * 4, RGB)
for layer in reversed(image.layers):
layer_tile = canvas.new_layer(layer.name)
rotation = gimp.Image(drawable.width * 2, drawable.height * 2, RGB)
rot_base = rotation.new_layer('base')
pdb.gimp_edit_copy(layer)
selection = pdb.gimp_edit_paste(rot_base, False)
x_off, y_off = selection.offsets
pdb.gimp_layer_translate(selection, -x_off, -y_off)
pdb.gimp_floating_sel_anchor(selection)
selection = pdb.gimp_edit_paste(rot_base, False)
pdb.plug_in_rotate(rotation, selection, 1, False)
x_off, y_off = selection.offsets
pdb.gimp_layer_translate(selection, selection.width-x_off, -y_off)
pdb.gimp_floating_sel_anchor(selection)
selection = pdb.gimp_edit_paste(rot_base, False)
pdb.plug_in_rotate(rotation, selection, 2, False)
x_off, y_off = selection.offsets
pdb.gimp_layer_translate(selection, selection.width-x_off, selection.height-y_off)
pdb.gimp_floating_sel_anchor(selection)
selection = pdb.gimp_edit_paste(rot_base, False)
pdb.plug_in_rotate(rotation, selection, 3, False)
x_off, y_off = selection.offsets
pdb.gimp_layer_translate(selection, -x_off, selection.height-y_off)
pdb.gimp_floating_sel_anchor(selection)
pdb.gimp_edit_copy(rot_base)
selection = pdb.gimp_edit_paste(layer_tile, False)
x_off, y_off = selection.offsets
pdb.gimp_layer_translate(selection, -x_off, -y_off)
pdb.gimp_floating_sel_anchor(selection)
selection = pdb.gimp_edit_paste(layer_tile, False)
x_off, y_off = selection.offsets
pdb.gimp_layer_translate(selection, selection.width-x_off, -y_off)
pdb.gimp_floating_sel_anchor(selection)
selection = pdb.gimp_edit_paste(layer_tile, False)
x_off, y_off = selection.offsets
pdb.gimp_layer_translate(selection, selection.width-x_off, selection.height-y_off)
pdb.gimp_floating_sel_anchor(selection)
selection = pdb.gimp_edit_paste(layer_tile, False)
x_off, y_off = selection.offsets
pdb.gimp_layer_translate(selection, -x_off, selection.height-y_off)
pdb.gimp_floating_sel_anchor(selection)
pdb.gimp_drawable_offset(layer_tile, True, False, image.width, image.height)
if not pdb.gimp_item_get_visible(layer):
pdb.gimp_item_set_visible(layer_tile, False)
pdb.gimp_display_new(canvas)
pdb.gimp_displays_flush()
register(
'reflection_tile',
'Tiles an image to 16x the size with reflections',
'Tiles an image to 16x the size with reflections',
'Shoeboxam',
'Shoeboxam',
'2017',
"Reflection Tile",
"*",
[
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Input drawable", None)
],
[],
reflection_tile,
menu="<Image>/Filters/Custom")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment