Skip to content

Instantly share code, notes, and snippets.

@AlexanderPavlenko
Created December 21, 2017 14:11
Show Gist options
  • Save AlexanderPavlenko/5d58a472be6122238dbd603508b7205d to your computer and use it in GitHub Desktop.
Save AlexanderPavlenko/5d58a472be6122238dbd603508b7205d to your computer and use it in GitHub Desktop.

Revisions

  1. AlexanderPavlenko created this gist Dec 21, 2017.
    43 changes: 43 additions & 0 deletions vr_blur.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    #!/usr/bin/env python

    from gimpfu import *

    def vr_blur(image, layer):
    # width = 3840
    # height = 1.0*width*layer.height / layer.width
    # layer = pdb.gimp_drawable_transform_scale(layer, 0, 0, width-1, height-1, TRANSFORM_FORWARD, INTERPOLATION_LANCZOS, 1, 3, TRANSFORM_RESIZE_ADJUST)
    # layer.translate(0, 540 - layer.height/2)
    # pdb.gimp_layer_flatten(layer)
    upper = layer.copy()
    lower = layer.copy()
    image.add_layer(upper)
    image.add_layer(lower)
    upper.resize(layer.width, 1, 0, 0)
    lower.resize(layer.width, 1, 0, -layer.height+1)
    overlap = 42
    gap = (image.height - layer.height) / 2
    pdb.gimp_layer_scale(upper, layer.width, gap + overlap, 1)
    pdb.gimp_layer_scale(lower, layer.width, gap + overlap, 1)
    image.raise_layer(layer)
    image.raise_layer(layer)
    upper.translate(0, (upper.height - overlap) / -2)
    lower.translate(0, (lower.height - overlap) / 2)
    pdb.plug_in_gauss_rle(image, upper, 8, 1, 0)
    pdb.plug_in_gauss_rle(image, lower, 8, 1, 0)
    layer = pdb.gimp_image_merge_down(image,layer,CLIP_TO_IMAGE)
    pdb.gimp_image_merge_down(image,layer,CLIP_TO_IMAGE)

    register(
    "python_fu_vr_blur",
    "VR Blur",
    "Blurs top and bottom gaps",
    "Alexander Pavlenko",
    "MIT",
    "2017",
    "<Image>/Filters/Blur/VR",
    "*",
    [],
    [],
    vr_blur)

    main()