Quoting Arian Sanusi <ar...@sanusi.de>:

> I want to write a little script that takes an image and processes it
> with gimp-curves-spline. However i want to load the parameters for the
> procedure from a file or alternatively from previous settings of this
> filter, so I don't have to edit the script itself everytime i change the
> parameters. Could you give me a hint to one of those?

The following code should provide enough of a hint to get you started.  
It is functional but is not very robust (and you might prefer to  
retrieve all the channels in one pass).

; Retrieve the curve settings from a file which was saved with the
; "Export settings to file..." command in the Curves Menu.

; filename should be a fully qualified pathname of the file.
; channel should be one of (include the apostrophe):
;   'value
;   'red
;   'green
;   'blue
;   'alpha
; mode should be "0" to retrieve the spline (smooth) curve points
;      should be "1" to retrieve the freehand y-coordinates

; Return value is list of either
;   (number-of-spline-coordinates x0 y0 x1 y1 ... xN yN)
; or
;   (number-of-freehand-coordinates y0 y1 y2 ... yN)

(define (retrieve-curve filename channel mode)
   (let* (
       (port (open-input-file filename))
       (cts-curve 0)
       (cts-channel 0)
     (when (eqv? (peek-char port) #\#)
       (read-char port)
       (while (not (eqv? (read-char port) #\newline))
       (read-char port)
     (read port) ; time
     (set! cts-channel (cadr (read port)))
     (set! cts-curve (cdr (read port)))
     (while (not (eqv? cts-channel channel))
       (read port) ; time
       (set! cts-channel (cadr (read port)))
       (set! cts-curve (cdr (read port)))
     (close-input-port port)
     (if (= mode 0)
       (cdaddr cts-curve) ; smooth
       (cdar (cddddr cts-curve)) ; freehand

Gimp-user mailing list

Reply via email to