Last active
August 29, 2015 14:28
-
-
Save mieki256/42b02d71007852dca03b to your computer and use it in GitHub Desktop.
GIMPの全レイヤー・複数レイヤーに対して一括で色調補正もしくはコントラスト変更を行うScript-fu。Multiple Layer Actions ( http://gimpscripts.com/2014/01/multiple-layer-actions/ ) を参考に記述。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Multiple Layer Actions fork HSC rel 1.0 | |
; Created by mieki256 | |
; | |
; Original scripts : Multiple Layer Actions rel 5.1 Created by Graechan | |
; Comments directed to http://gimpchat.com or http://gimpscripts.com | |
; | |
; License: GPLv3 | |
; 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. | |
; | |
; To view a copy of the GNU General Public License | |
; visit: http://www.gnu.org/licenses/gpl.html | |
; | |
; | |
; ------------ | |
;| Change Log | | |
; ------------ | |
; Rel 1.0 - fork. Added Actions for Hue-Saturation, Brightness-Contrast (by mieki256) | |
; | |
; Change Log - Multiple Layer Actions (Original script) | |
; Rel 0.01 - Initial Release | |
; Rel 0.02 - Bugfix for Layers with Locked Pixels, Added additional actions 'Clear Selection' and 'Layer to Image Size' | |
; Rel 0.03 - Enabled layer group functionality | |
; Rel 0.04 - Added Additional Actions | |
; Rel 0.05 - Added Actions for Color: Desaturate, Colorify and Color Balance | |
; Rel 05.1 - Added Additional Actions | |
; | |
(define actions-menu-hsc | |
'( | |
"Hue-Saturation(settings below)" | |
"Brightness-Contrast(settings below)" | |
)) | |
(define (get-all-real-layers image) | |
(define (get-children group) | |
(let loop ((children (vector->list (cadr (gimp-item-get-children group)))) | |
(sub-layers '()) ) | |
(if (null? children) | |
(reverse sub-layers) | |
(loop (cdr children) | |
(if (zero? (car (gimp-item-is-group (car children)))) | |
(cons (car children) sub-layers) | |
(append sub-layers (get-children (car children))) ))))) | |
(let loop ((top-layers (vector->list (cadr (gimp-image-get-layers image)))) | |
(all-layers '()) ) | |
(if (null? top-layers) | |
all-layers | |
(loop (cdr top-layers) | |
(if (zero? (car (gimp-item-is-group (car top-layers)))) | |
(append all-layers (list (car top-layers))) | |
(append all-layers (get-children (car top-layers)))) )))) | |
(define (script-fu-multiple-layer-actions-hsc | |
image drawable | |
listType | |
exclude | |
actionType | |
huerange | |
hueoffset | |
lightness | |
saturation | |
brightness | |
contrast | |
) | |
(gimp-image-undo-group-start image) | |
(let* ( | |
(layerList 0) | |
(lockList 0) | |
(layerId 0) | |
) | |
;;------------------------------- | |
;;set the pre-conditions | |
(set! lockList (let loop ((layers (vector->list (cadr (gimp-image-get-layers image)))) | |
(layerList '()) ) | |
(if (null? layers) | |
(reverse layerList) | |
(loop (cdr layers) | |
(if (zero? (car (gimp-item-get-lock-content (car layers)))) | |
layerList | |
(cons (car layers) lockList) ))))) | |
(map (lambda (x) (gimp-item-set-lock-content x FALSE)) lockList) | |
(if (or (= actionType 5) (= actionType 6)) (gimp-context-set-background sf-color)) | |
(if (and (= actionType 8) (= listType 0)) (set! exclude TRUE)) | |
;;----------------------------------------------------------------------- | |
;;set the List Types | |
(cond | |
((= listType 0) ;All Layers | |
(set! layerList (get-all-real-layers image)) | |
(if (= exclude TRUE) (set! layerList (delq drawable layerList))) ;remove the drawable from the 'layerList' | |
) ;end All Layers | |
((= listType 1) ;Linked Layers | |
(set! layerList (let loop ((layers (get-all-real-layers image)) | |
(layerList '()) ) | |
(if (null? layers) | |
(reverse layerList) | |
(loop (cdr layers) | |
(if (zero? (car (gimp-drawable-get-linked (car layers)))) | |
layerList | |
(cons (car layers) layerList) ))))) | |
(if (= exclude TRUE) (set! layerList (delq drawable layerList))) ;remove the drawable from the 'layerList' | |
) ;end Linked Layers | |
((= listType 2) ;Non Linked Layers | |
(set! layerList (let loop ((layers (get-all-real-layers image)) | |
(layerList '()) ) | |
(if (null? layers) | |
(reverse layerList) | |
(loop (cdr layers) | |
(if (not(zero? (car (gimp-drawable-get-linked (car layers))))) | |
layerList | |
(cons (car layers) layerList) ))))) | |
(if (= exclude TRUE) (set! layerList (delq drawable layerList))) ;remove the drawable from the 'layerList' | |
) ;end Non Linked Layers | |
) ;endcond | |
;;-------------------------------------------------------------------------------------------------------------------- | |
;;------------------------------------------------------------------------------------------------------------------------ | |
;;Actions to perform | |
(cond | |
((= actionType 0) (map (lambda (x) (gimp-hue-saturation x huerange hueoffset lightness saturation)) layerList)) | |
((= actionType 1) (map (lambda (x) (gimp-brightness-contrast x brightness contrast)) layerList)) | |
) ;end actions cond | |
;;------------------------------------------------------------------------------------------------------ | |
;;reset pre-conditions | |
(map (lambda (x) (gimp-item-set-lock-content x TRUE)) lockList) | |
;;--------------------------------------------------------------------------------------------------- | |
(gimp-displays-flush) | |
(gimp-image-undo-group-end image);preserve-lum cyan-red magenta-green yellow-blue | |
) | |
) | |
(script-fu-register | |
"script-fu-multiple-layer-actions-hsc" | |
"Muliple Layer Actions HSC..." | |
"Set the type of Layers to Effect and wether to exclude the active Layer then the action you want done" | |
"Graechan, mieki256" | |
"Graechan - http://gimpchat.com , mieki256 " | |
"2015/08" | |
"RGB*" | |
SF-IMAGE "image" 0 | |
SF-DRAWABLE "drawable" 0 | |
SF-OPTION "Layers to Affect" '("All layers" "Linked Layers" "Non-Linked Layers") | |
SF-TOGGLE "Exclude Active Layer" FALSE | |
SF-OPTION "Actions" actions-menu-hsc | |
SF-OPTION "Hue range" '("All" "Red" "Yellow" "Green" "Cyan" "Blue" "Magenta") | |
SF-ADJUSTMENT _"Hue offset" '(0 -180 180 1 10 0 0) | |
SF-ADJUSTMENT _"Lightness" '(0 -100 100 1 10 0 0) | |
SF-ADJUSTMENT _"Saturation" '(0 -100 100 1 10 0 0) | |
SF-ADJUSTMENT _"Brightness" '(0 -127 127 1 10 0 0) | |
SF-ADJUSTMENT _"Contrast" '(0 -127 127 1 10 0 0) | |
) | |
(script-fu-menu-register | |
"script-fu-multiple-layer-actions-hsc" | |
"<Image>/Layer/All Layers") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment