RSS/Atom feed Twitter
Site is read-only, email is disabled

gimp batch mode - how to load settings from file?

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

gimp batch mode - how to load settings from file? Arian Sanusi 25 Jan 12:31
  gimp batch mode - how to load settings from file? saulgoode@flashingtwelve.brickfilms.com 26 Jan 04:52
Arian Sanusi
2010-01-25 12:31:03 UTC (almost 15 years ago)

gimp batch mode - how to load settings from file?

Hi,

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?

regards, Arian

saulgoode@flashingtwelve.brickfilms.com
2010-01-26 04:52:23 UTC (almost 15 years ago)

gimp batch mode - how to load settings from file?

Quoting Arian Sanusi :

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 )
)
)