Good morning, All!
I needed a simple script to mirror half an image (L to R, R to L, Top to Bottom, B to T). I couldn't find one elsewhere so I wrote my own. Not sure if anyone would find this valuable, but I'm uploading it here. It's been awhile since I've done any scripting, but I made sure all code is in accordance with the updated scheme for GIMP.
You can find the script at Filters > Render > Mirror Image...
Cheers. Art
(define (mirror-image image drw horv side)
(let* (
(originalLayer (car (gimp-image-get-active-layer image)))
(copyLayer 0)
(width (car (gimp-drawable-width originalLayer)))
(height (car (gimp-drawable-height originalLayer)))
(cX (/ width 2))
(cY (/ height 2))
)
(gimp-image-undo-group-start image)
(gimp-layer-add-alpha originalLayer)
(set! copyLayer (car (gimp-layer-copy originalLayer TRUE)))
(gimp-image-add-layer image copyLayer -1)
(if (= horv 0)
(begin
(gimp-image-select-rectangle image CHANNEL-OP-ADD 0 0 cX height)
(if (= side 0)
(begin
(gimp-selection-invert image)
(gimp-edit-clear copyLayer)
(gimp-selection-none image)
(gimp-item-transform-flip-simple copyLayer ORIENTATION-HORIZONTAL TRUE cX)
)
(begin
(gimp-edit-clear copyLayer)
(gimp-selection-none image)
(gimp-item-transform-flip-simple copyLayer ORIENTATION-HORIZONTAL TRUE cX)
)
))
)
(if (= horv 1)
(begin
(gimp-image-select-rectangle image CHANNEL-OP-ADD 0 0 width cY)
(if (= side 0)
(begin
(gimp-selection-invert image)
(gimp-edit-clear copyLayer)
(gimp-selection-none image)
(gimp-item-transform-flip-simple copyLayer ORIENTATION-VERTICAL TRUE cY)
)
(begin
(gimp-edit-clear copyLayer)
(gimp-selection-none image)
(gimp-item-transform-flip-simple copyLayer ORIENTATION-VERTICAL TRUE cY)
)
))
)
(gimp-image-merge-down image copyLayer CLIP-TO-IMAGE)
(set! originalLayer (car (gimp-image-get-active-layer image)))
; Allow for the GIMP settings to be restored prior to running the script
(gimp-context-push)
(gimp-displays-flush)
(gimp-image-undo-group-end image)
; Return GIMP settings back to those used prior to script
(gimp-context-pop)
)
)
(script-fu-register "mirror-image"
"<Image>/Filters/Render/Mirror Image..."
""
"Art Wade"
"Art Wade"
"September 17, 2016"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-OPTION "Horizontal or Vertical?" '("Horizontal"
"Vertical")
SF-OPTION "Left or Right (Top or Bottom)?" '("Left (Top if Vertical)"
"Right (Bottom if Vertical)")
)