[Gimp-user] Problems with changing layer mode in scheme



Hi,

sorry for the long intro, but I tend to believe that context is
important.

When I have the time, I'm gradually trying to 'process' raw photos
I've taken in the past.  A brief overview is: select a base exposure
and two others for shadows and highlights (typically ±2EV), put
those in layers with masks, remove the masks, merge down.  After
that I do visual correction (lens distortion, rotation, perspective
distortion) and then things like tone mapping and sharpenbing.

I got back to this a few monbths ago and discovered that although
it sounds obvious to use the base image ("correct exposure") to
create the masks - i.e. what is dark in that, rather than in the
overexposed shadow layer, should be retrieved from the shadow layer,
and vice versa - I got horrible results.  Eventually I found out
about "lighten only" and "darken only" layer modes.

So, I now have enough confidence in that approach to try using it.
But I still need to make decisions about which exposures to use, and
what other things to do, so each picture still takes a long time.
But the "merge three exposures" part is one of hte slowest parts of
hte process and is more likely to work well when scripted: from time
to time I do something wrong when I do it manually.

I found load_for_hdr_0.scm which appears to be doing similar things
to what I want to do, so I've been trying to hack on it.  This is
with gimp-2.8.20, I'll give it a go in my machine running once it
seems to work.  Hmm, for those of us without a CS background,
scheme/lisp is hard.  I've been trying to set the layer mode in the
appropriate part of my fork of that script.

It started out before my changes as -

(define (process-single-image 
                dest-image 
                source-image 
                dest-layer-name 
                desaturate-option 
                invert-option
                blur-radius) 
    (let* ( 
            (layer (copy-image-as-new-layer dest-image source-image)))
    
    (gimp-layer-set-name layer dest-layer-name)
    (gimp-desaturate-full (car (gimp-image-get-active-drawable
source-image)) desaturate-option)
...

First I tried adding dest-layer-mode after dest-layer-name in the
definitions, and passing LIGHTEN-ONLY-MODE (that is, 10) after the
layer name, then adding

    (gimp-layer-set-mode layer dest-layer-mode)

after gimp-layer-set-name, but I got an error from the following
gimp-desaturate-full :

Error: ( : 1) Procedure execution of gimp-desaturate-full failed on
invalid input arguments: Procedure 'gimp-desaturate-full' has been
called with value '10' for argument 'desaturate-mode' (#2, type
GimpDesaturateMode). This value is out of range.

That puzzles me, the parameters were in order, but I tried to work
around it by moving dest-layer-mode to the last parameter, after
blur-radius.  That ran without error, but the added layers are still
in normal mode. :-(

I'm also at a loss about how to debug this - the examples I can find
are all pretty short, this script (ignoring comments) is all-but 100
lines, and I don't seem to be able to paste into the script-fu
window (running xfce on this machine).

Any suggestions, please ? (Other than using Python - I prefer to
build from source, the impenetrable deps in some Python scripts
annoy me, and taking a quick look at two very-long Python scripts
which appear to be for this sort of use I found their code totally
impenetrable, and they did not come close to doing what I wanted).

ĸen
-- 
`I shall take my mountains', said Lu-Tze. `The climate will be good
for them.'     -- Small Gods


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]