Chromatic Aberration Plugin for GIMP
A chromatic aberration plugin for GNU Image Manipulation Program. Tested on version 2.10.
See GIMP Plugin Documentation for installation procedure.
;
; 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/>.
(define (script-fu-chromatic-aberration inImage inLayer inNumber)
(let* (
(theImage inImage)
(theLayer inLayer)
(theHeight (car (gimp-drawable-height theLayer)))
(theWidth (car (gimp-drawable-width theLayer)))
(aberrationGroup 0)
(redLayer 0)
(greenLayer 0)
(blueLayer 0)
(aberrationLayer 0)
)
(gimp-context-push)
(gimp-context-set-defaults)
(gimp-image-undo-group-start theImage)
(set! aberrationGroup (car (gimp-layer-group-new theImage)))
(gimp-item-set-name aberrationGroup "Aberration")
(gimp-image-insert-layer theImage aberrationGroup 0 0)
(set! blueLayer (car (gimp-layer-copy theLayer TRUE)))
(gimp-item-set-name blueLayer "Blue")
(gimp-image-insert-layer theImage blueLayer aberrationGroup 0)
(gimp-item-set-visible blueLayer TRUE)
(plug-in-colors-channel-mixer RUN-INTERACTIVE theImage blueLayer FALSE 0 0 0 0 0 0 0 0 1)
(gimp-layer-set-mode blueLayer LAYER-MODE-NORMAL)
(set! greenLayer (car (gimp-layer-copy theLayer TRUE)))
(gimp-item-set-name greenLayer "Green")
(gimp-image-insert-layer theImage greenLayer aberrationGroup 0)
(gimp-item-set-visible greenLayer TRUE)
(plug-in-colors-channel-mixer RUN-INTERACTIVE theImage greenLayer FALSE 0 0 0 0 1 0 0 0 0)
(gimp-layer-set-mode greenLayer LAYER-MODE-ADDITION)
(set! redLayer (car (gimp-layer-copy theLayer TRUE)))
(gimp-item-set-name redLayer "Red")
(gimp-image-insert-layer theImage redLayer aberrationGroup 0)
(gimp-item-set-visible redLayer TRUE)
(plug-in-colors-channel-mixer RUN-INTERACTIVE theImage redLayer FALSE 1 0 0 0 0 0 0 0 0)
(gimp-layer-set-mode redLayer LAYER-MODE-ADDITION)
;Wipes layers into one another to smooth the spectrum.
;Motion blur is performed before lens distortion to hide frame edges.
(plug-in-mblur-inward RUN-NONINTERACTIVE theImage redLayer 2 (/ inNumber 13) 0 (/ theWidth 2) (/ theHeight 2))
(plug-in-mblur-inward RUN-NONINTERACTIVE theImage greenLayer 2 (/ inNumber 26) 0 (/ theWidth 2) (/ theHeight 2))
(plug-in-mblur RUN-NONINTERACTIVE theImage greenLayer 2 (/ inNumber 26) 0 (/ theWidth 2) (/ theHeight 2))
(plug-in-mblur RUN-NONINTERACTIVE theImage blueLayer 2 (/ inNumber 13) 0 (/ theWidth 2) (/ theHeight 2))
;Red layer is distorted twice as much as green; both are "zoomed in" while blue stays the same.
(plug-in-lens-distortion RUN-INTERACTIVE theImage redLayer 0 0 (/ (* -1 inNumber) 5.0) 0 0 0)
(plug-in-lens-distortion RUN-INTERACTIVE theImage greenLayer 0 0 (/ (* -1 inNumber) 10.0) 0 0 0)
(set! aberrationLayer (car (gimp-image-merge-layer-group theImage aberrationGroup)))
(gimp-image-undo-group-end theImage)
(gimp-displays-flush)
(gimp-context-pop)
)
)
(script-fu-register "script-fu-chromatic-aberration"
_"_Chromatic Aberration..."
_"Apply a simple chromatic aberration effect."
"Matthew Schellenberg"
"2024, Matthew Schellenberg"
"January 29, 2024"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT _"Aberration" '(40 0 150 1 1 0 0)
)
(script-fu-menu-register "script-fu-chromatic-aberration" "<Image>/Filters/Blur")