Skip to content

Instantly share code, notes, and snippets.

@A2va
Last active March 2, 2020 15:08
Show Gist options
  • Save A2va/52198de13919b2f2c2d65da1bc56a9a6 to your computer and use it in GitHub Desktop.
Save A2va/52198de13919b2f2c2d65da1bc56a9a6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Plug-in: SmoothZoom
# Author: A2va
# Version: 1.0
# Date: 28.02.2020
# Tested with: GIMP 2.10
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <https://www.gnu.org/licenses/>. 1
#Install
#Open the Gimp user directory.
#On Windows it is this path C:\Users\Username\AppData\Roaming\GIMP\2.10\plug-ins.
#and copy the python file
from gimpfu import *
def smooth_zoom_video_editing(image, drawable):
#Create 8 layers
parent = pdb.gimp_item_get_parent(drawable)
position = pdb.gimp_image_get_item_position(image, drawable)
#Layer0
layer0 = pdb.gimp_layer_copy(drawable, TRUE)
pdb.gimp_image_insert_layer(image, layer0, parent, position)
layer0.name = "0"
#Layer1
layer1 = pdb.gimp_layer_copy(drawable, TRUE)
pdb.gimp_image_insert_layer(image, layer1, parent, position)
layer1.name = "1"
#Layer2
layer2 = pdb.gimp_layer_copy(drawable, TRUE)
pdb.gimp_image_insert_layer(image, layer2, parent, position)
layer2.name = "2"
#Layer3
layer3 = pdb.gimp_layer_copy(drawable, TRUE)
pdb.gimp_image_insert_layer(image, layer3, parent, position)
layer3.name = "3"
#Layer4
layer4 = pdb.gimp_layer_copy(drawable, TRUE)
pdb.gimp_image_insert_layer(image, layer4, parent, position)
layer4.name = "4"
#Layer5
layer5 = pdb.gimp_layer_copy(drawable, TRUE)
pdb.gimp_image_insert_layer(image, layer5, parent, position)
layer5.name = "5"
#Layer6
layer6 = pdb.gimp_layer_copy(drawable, TRUE)
pdb.gimp_image_insert_layer(image, layer6, parent, position)
layer6.name = "6"
#Layer7
layer7 = pdb.gimp_layer_copy(drawable, TRUE)
pdb.gimp_image_insert_layer(image, layer7, parent, position)
layer7.name = "7"
#Determine the width and height of image
#and the offset on X and Y
width=pdb.gimp_image_width(image)
height=pdb.gimp_image_height(image)
width_new=width*1.5
height_new=height*1.5
offsetX= width*0.25
offsetY= height*0.25
pdb.gimp_image_resize(image, width_new, height_new, offsetX, offsetY)
#Move the 8 layer
#Layer0
layer0_X,layer0_Y=pdb.gimp_drawable_offsets(layer0)
pdb.gimp_layer_translate(layer0,(width_new-offsetX-layer0_X),(offsetY-layer0_Y))
#Layer1
layer1_X,layer1_Y=pdb.gimp_drawable_offsets(layer1)
pdb.gimp_layer_translate(layer1,(-(width_new/2)-layer1_X),(offsetY-layer1_Y))
#Layer2
layer2_X,layer2_Y=pdb.gimp_drawable_offsets(layer2)
pdb.gimp_layer_translate(layer2,(width_new-offsetX-layer2_X),(offsetY-height-layer2_Y))
#Layer3
layer3_X,layer3_Y=pdb.gimp_drawable_offsets(layer3)
pdb.gimp_layer_translate(layer3,(-(width_new/2)-layer3_X),(offsetY-height-layer3_Y))
#Layer4
layer4_X,layer4_Y=pdb.gimp_drawable_offsets(layer4)
pdb.gimp_layer_translate(layer4,(width_new-offsetX-layer4_X),(height_new-offsetY-layer4_Y))
#Layer5
layer5_X,layer5_Y=pdb.gimp_drawable_offsets(layer5)
pdb.gimp_layer_translate(layer5,(-(width_new/2)-layer5_X),(height_new-offsetY-layer5_Y))
#Layer6
layer6_X,layer6_Y=pdb.gimp_drawable_offsets(layer6)
pdb.gimp_layer_translate(layer6,(offsetX-layer6_X),(offsetY-height-layer6_Y))
#Layer7
layer7_X,layer7_Y=pdb.gimp_drawable_offsets(layer7)
pdb.gimp_layer_translate(layer7,(offsetX-layer7_X),(offsetY+height-layer7_Y))
register(
"smooth_zoom_video_editing",
"SmoothZoom",
"That create a image for a smooth zoom transition",
"A2va",
"A2va",
"2020",
"SmoothZoom",
"", # Image type
[
(PF_IMAGE, "image", "", None),
(PF_DRAWABLE, "drawable", "", None)
],
[],
smooth_zoom_video_editing, menu="<Image>/Filters")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment