0

I'm trying to set up a script for raw photos, to allow me to add two copies of the existing file (all taken from ufraw), at different exposures so I can recover shadow and highlight detail. The part for the shadow file is now working, hard-coded to use the same layer for its mask and with a mode of NORMAL.

But I want to pass an option for the shadow mask, so that I can take it from the shadow layer or the base layer (the normal exposure) AND set the mode to NORMAL or LIGHTEN-ONLY. The following code does not error:

(cond ( < shadow-option 2 ) (define (sm-source shadow-layer)) 
 (else (define (sm-source base-layer))))

 (cond ( = shadow-option 0 ) (define (shadow-mode NORMAL)) 
 (else (define (shadow-mode LIGHTEN-ONLY))))

Maybe my cond tests are not going to do what I want, but AFAICS both sm-source and shadow-mode must have a value, either from the test being true, or from the else ?

But both appear to not be defined when I try to reference them. The first use is on the next line of my script: (gimp-layer-set-mode shadow-layer shadow-mode) But I get Error: ( : 1) eval: unbound variable: shadow-mode. If I comment that line and replace it by a hardcoded mode, I then get a similar error for sm-source.

Matthew Verstraete
  • 6,335
  • 22
  • 67
  • 123
  • It's often regarded as bad form to answer your own questions, but I've found a workaround. At each point I have an either/or decision. In the end, setting them out as if ... else AND doing that to run the command (instead of setting a variable for later) AND continuing to use define for smask-layer (set! makes it local, so unusable in following statements) I think I've got it working : passed both my test images for all variants. – zarniwhoop Apr 25 '17 at 23:18
  • `; Set the layer mode for the shadow layer -` `; default will be normal, else lighten` `(if (= shadow-option 0) (gimp-layer-set-mode shadow-layer NORMAL)` ` ; else` ` (gimp-layer-set-mode shadow-layer LIGHTEN-ONLY)` `)` – zarniwhoop Apr 25 '17 at 23:19
  • Sorry about formatting, can't fix that. The other command is (/me swears at being treated as instead of newline, and leaves in '+' from my diff to show start of lines) `+(if (= shadow-option 2) (define smask-layer (car (gimp-layer-copy base-layer 0))) + ; else + (define smask-layer (car (gimp-layer-copy shadow-layer 0))) +) – zarniwhoop Apr 25 '17 at 23:22

0 Answers0