Skip to content

Instantly share code, notes, and snippets.

@blippy
Created June 16, 2016 11:14
Show Gist options
  • Select an option

  • Save blippy/0144c2d948b6bc7049c38ec321210710 to your computer and use it in GitHub Desktop.

Select an option

Save blippy/0144c2d948b6bc7049c38ec321210710 to your computer and use it in GitHub Desktop.
Gimp cross-processing
;;; Copyright (c) 2011 Cardinal Peak
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining a copy
;;; of this software and associated documentation files (the "Software"), to deal
;;; in the Software without restriction, including without limitation the rights
;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;;; copies of the Software, and to permit persons to whom the Software is
;;; furnished to do so, subject to the following conditions:
;;;
;;; The above copyright notice and this permission notice shall be included in
;;; all copies or substantial portions of the Software.
;;;
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
;;; THE SOFTWARE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Cross-processing script for the gimp
;
; Description of cross processing:
; http://en.wikipedia.org/wiki/Cross_processing
;
; This script automates the tutorial found at:
; http://www.jesusda.com/blog/index.php?id=375
(define (script-fu-xpro inImage inLayer)
; start an undoable group of operations
(gimp-image-undo-group-start inImage)
; remap curves for red/green/blue components
(gimp-curves-spline inLayer HISTOGRAM-RED 10 #(0 0 88 47 170 188 221 249 255 255))
(gimp-curves-spline inLayer HISTOGRAM-GREEN 8 #(0 0 65 57 184 208 255 255))
(gimp-curves-spline inLayer HISTOGRAM-BLUE 4 #(0 29 255 226))
; duplicate image layer, mark it as 50% opacity, and overlay it
(let* ((newLayer (car (gimp-layer-copy inLayer FALSE))))
(gimp-image-add-layer inImage newLayer -1)
(gimp-layer-set-opacity newLayer 50)
(gimp-layer-set-mode newLayer OVERLAY-MODE))
; create a new greenish-yellow layer at 10% opacity and overlay it
(let* ((newLayer (car (gimp-layer-new inImage (car (gimp-image-width inImage))
(car (gimp-image-height inImage)) RGB-IMAGE
"GreenishYellow" 10 OVERLAY-MODE))))
(gimp-context-set-foreground '(0 255 186))
(gimp-drawable-fill newLayer FOREGROUND-FILL)
(gimp-image-add-layer inImage newLayer -1))
; display cross processed image, and end the undoable group of operations
(gimp-displays-flush)
(gimp-image-undo-group-end inImage))
(script-fu-register
"script-fu-xpro"
"Xpro"
"Cross-process an image."
"Ben Mesander"
"(C) Cardinal Peak, 2011"
"Thursday"
""
SF-IMAGE "The Image" 0
SF-DRAWABLE "The Layer" 0
)
(script-fu-menu-register "script-fu-xpro" "<Image>/Filters/Xpro")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment