Skip to content

Instantly share code, notes, and snippets.

@aausch
Last active September 4, 2019 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aausch/6687871 to your computer and use it in GitHub Desktop.
Save aausch/6687871 to your computer and use it in GitHub Desktop.
automatically overlaying two images, using Gimp
;; script for automatically overlaying two images,
;; for comparison, in gimp.
;;
;; 1. save the file in your scripts directory
;; (/Applications/Gimp.app/Contents/MacOS/Resources/share/gimp/2.0/scripts/ or
;; /Users/[user]/Library/Application Support/GIMP/2.8/plug-ins on my mac)
;; 2. generate two images to compare
;; 3. run:
;; bash: /Applications/Gimp.app/Contents/MacOS/gimp-2.8 -b '(script-fu-overlay "image1.pdf" "image2.jpg")'
;;
;; image format is flexible, and can be anything gimp will import from
;;
;; Copyright 2013, Alex Ausch
;; Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/
(define (script-fu-overlay img1 img2)
(let*
(
(position1 -1)
(position2 -2)
(back-layer nil)
(front-layer nil)
(width 0)
(height 0)
(image (car (gimp-image-new 10 10 RGB)))
(drawable (car (gimp-image-get-active-layer image)))
)
(set! back-layer(car(gimp-file-load-layer RUN-NONINTERACTIVE image img1)))
(set! front-layer(car(gimp-file-load-layer RUN-NONINTERACTIVE image img2)))
(set! width (car (gimp-drawable-width back-layer)))
(set! height (car (gimp-drawable-height back-layer)))
(gimp-image-resize image width height 0 0)
(gimp-image-insert-layer image back-layer 0 position1)
(gimp-image-insert-layer image front-layer 0 position2)
(gimp-layer-set-opacity front-layer 40)
(gimp-display-new image)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment