Skip to content

Instantly share code, notes, and snippets.

@A2va
Created March 2, 2020 15:08
Show Gist options
  • Save A2va/beb0e0963c12c0ba7bde26aabb683b56 to your computer and use it in GitHub Desktop.
Save A2va/beb0e0963c12c0ba7bde26aabb683b56 to your computer and use it in GitHub Desktop.
; 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\script.
;and copy the script file
;Use this script file OR the Scheme file but not both
(define (smooth_zoom_video_editing image drawable)
(let* (
(width (car (gimp-drawable-width drawable)))
(height (car (gimp-drawable-height drawable)))
(layer0 (car (gimp-layer-copy drawable FALSE)))
(layer1 (car (gimp-layer-copy drawable FALSE)))
(layer2 (car (gimp-layer-copy drawable FALSE)))
(layer3 (car (gimp-layer-copy drawable FALSE)))
(layer4 (car (gimp-layer-copy drawable FALSE)))
(layer5 (car (gimp-layer-copy drawable FALSE)))
(layer6 (car (gimp-layer-copy drawable FALSE)))
(layer7 (car (gimp-layer-copy drawable FALSE)))
(width_new 0)
(height_new 0)
(offsetX 0)
(offsetY 0)
)
;Determine the width and height of image
;and the offset on X and Y
(set! width_new (* width 1.5))
(set! height_new (* height 1.5))
(set! offsetX (/ width 4))
(set! offsetY (/ height 4))
(gimp-image-resize image width_new height_new offsetX offsetY)
;Create 8 layers
(gimp-item-set-name layer0 "0")
(gimp-image-insert-layer image layer0 0 0)
(gimp-item-set-name layer1 "1")
(gimp-image-insert-layer image layer1 0 0)
(gimp-item-set-name layer2 "2")
(gimp-image-insert-layer image layer2 0 0)
(gimp-item-set-name layer3 "3")
(gimp-image-insert-layer image layer3 0 0)
(gimp-item-set-name layer4 "4")
(gimp-image-insert-layer image layer4 0 0)
(gimp-item-set-name layer5 "5")
(gimp-image-insert-layer image layer5 0 0)
(gimp-item-set-name layer6 "6")
(gimp-image-insert-layer image layer6 0 0)
(gimp-item-set-name layer7 "7")
(gimp-image-insert-layer image layer7 0 0)
;Move the layer
(gimp-layer-translate layer0 (- width_new offsetX) offsetY)
;Layer1
(gimp-layer-translate layer1 (- ( / width_new 2)) offsetY)
;Layer2
(gimp-layer-translate layer2 (- width_new offsetX) ( - offsetY height))
;Layer3
(gimp-layer-translate layer3 (- ( / width_new 2)) ( - offsetY height))
;Layer4
(gimp-layer-translate layer4 (- width_new offsetX) ( - height_new offsetY))
;Layer5
(gimp-layer-translate layer5 (- ( / width_new 2)) ( - height_new offsetY))
;Layer6
(gimp-layer-translate layer6 offsetX ( - offsetY height))
;Layer7
(gimp-layer-translate layer7 offsetX ( + offsetY height))
(gimp-displays-flush)
)
)
(script-fu-register "smooth_zoom_video_editing"
"Smooth Zoom"
"That create a image for a smooth zoom transition"
"A2va"
"A2va"
"28.02.2020"
""
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0
)
(script-fu-menu-register "smooth_zoom_video_editing"
"<Image>/Filters")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment