Plugin: Stencil Chrome: allow user not to choose a secondary image

When the user does not choose a file of a secondary image,
use a copy of the primary image as the secondary image.
Rather than throw an error.
The filter still has effects, if not quite the same as when user
chooses a secondary image that is not the primary image.
This commit is contained in:
lloyd konneker 2024-09-17 17:49:29 -04:00
parent f4ae230e4d
commit dd241e9c71
1 changed files with 45 additions and 1 deletions

View File

@ -3,9 +3,54 @@
; This script requires a grayscale image containing a single layer.
; This layer is used as the mask for the SOTA chrome effect
; An adaptor from the original signature to a new inner signature
;
; Adapts env-map, an image file to be opened, to banding-img, an open image.
; When user doesn't choose a file, banding-img is a copy of the primary mask-img.
; The effect is something, if not the same as when user chooses a different image
; than the primary image.
; Originally, the file chooser had a default, so the user could NOT choose a None file
; for the env-map file, the secondary image.
;
; The UI design for the secondary "banding image":
; the user must choose a file of an image instead of an open image.
; FUTURE: require the user to choose an open image for the secondary image.
;
; The inner algorithm requires a GRAY image without an alpha.
; FUTURE: also adapt image type by working on a copy,
; converting image mode to GRAY, and deleting alpha.
; For user friendliness, the filter should work on an image of any mode
; and regardless of any alpha channels.
;
; The filter is generating a new image, having alpha channels.
; Since the result image is new, the filter should not concern itself
; whether the source image has alpha channels that might be destroyed.
(define (script-fu-sota-chrome-it mask-img mask-drawables chrome-saturation
chrome-lightness chrome-factor env-map hc cc carve-white)
; convert choice of secondary image file to an open image
(let ((banding-img ; secondary, other image
; when user chose no env-map secondary image file
(if (= (string-length env-map) 0)
; copy source image
(car (gimp-image-duplicate mask-img))
; else open chosen file
(car (gimp-file-load RUN-NONINTERACTIVE env-map)))))
; call the inner filter with adapted args
(chrome-it-inner mask-img mask-drawables chrome-saturation
chrome-lightness chrome-factor banding-img hc cc carve-white))
; Inner deletes banding-img
)
; The original filter, now taking a image:banding-img instead of file:env-map
(define (chrome-it-inner mask-img mask-drawables chrome-saturation
chrome-lightness chrome-factor banding-img hc cc carve-white)
(define (set-pt a index x y)
(begin
(aset a (* index 2) x)
@ -75,7 +120,6 @@
)
(let* (
(banding-img (car (gimp-file-load RUN-NONINTERACTIVE env-map)))
(banding-layer (aref (cadr (gimp-image-get-selected-drawables banding-img)) 0))
(banding-height (car (gimp-drawable-get-height banding-layer)))
(banding-width (car (gimp-drawable-get-width banding-layer)))