API to parse a saved GIMP's curves file
This discussion is connected to the gimp-developer-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.
API to parse a saved GIMP's curves file | Alessandro Francesconi | 25 Sep 09:21 |
API to parse a saved GIMP's curves file | Kevin Payne | 25 Sep 11:32 |
API to parse a saved GIMP's curves file | Kevin Brubeck Unhammer | 27 Sep 07:13 |
API to parse a saved GIMP's curves file | Kevin Cozens | 26 Sep 14:48 |
API to parse a saved GIMP's curves file | Joao S. O. Bueno | 26 Sep 17:21 |
API to parse a saved GIMP's curves file
Hello, I’m developing a plugin that must read the contents of a GIMP “curves” file and build an array of points, in order to finally call the gimp_curves_spline() function:http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpcolor.html#gimp-curves-spline
I’m talking about the kind of file that is produced when a user goes to the Curves dialog and clicks on “Export Settings to File”. An example of file is the following:
# GIMP curves tool settings
(time 0)
(channel value)
(curve
(curve-type smooth)
(n-points 17)
(points 34 0.000000 0.000000 -1.000000 -1.000000 [other X Y points...])
(n-samples 256)
(samples 256 0.000000 0.012218 0.024425 0.036608 0.048757 0.060859 0.072904 0.084878 0.096772 0.108573 0.120270 0.131851 0.143305 0.154619 0.165783 0.176785 0.187612 0.198255 0.208700 0.218937 0.228954 0.238739 0.248281 0.257568 0.266589 0.275331 0.283784 0.291935 0.299774 0.307288 [other samples...])
)
Is there a group of functions ready to be used to parse this kind of file? Or I need to build it my myself?
Thank you,
Ale
API to parse a saved GIMP's curves file
A couple of years ago I wrote a script-fu script to read curve files if that helps: http://www.gimptalk.com/index.php?/topic/50107-batch-edit-curves/
Kevin
From: alessandrofrancesconi@live.it To: gimp-developer-list@gnome.org
Date: Wed, 25 Sep 2013 09:21:55 +0000 Subject: [Gimp-developer] API to parse a saved GIMP's curves fileHello, Im developing a plugin that must read the contents of a GIMP curves file and build an array of points, in order to finally call the gimp_curves_spline() function:http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpcolor.html#gimp-curves-spline
Im talking about the kind of file that is produced when a user goes to the Curves dialog and clicks on Export Settings to File. An example of file is the following:
# GIMP curves tool settings
(time 0) (channel value)
(curve
(curve-type smooth)
(n-points 17)
(points 34 0.000000 0.000000 -1.000000 -1.000000 [other X Y points...]) (n-samples 256)
(samples 256 0.000000 0.012218 0.024425 0.036608 0.048757 0.060859 0.072904 0.084878 0.096772 0.108573 0.120270 0.131851 0.143305 0.154619 0.165783 0.176785 0.187612 0.198255 0.208700 0.218937 0.228954 0.238739 0.248281 0.257568 0.266589 0.275331 0.283784 0.291935 0.299774 0.307288 [other samples...]))
Is there a group of functions ready to be used to parse this kind of file? Or I need to build it my myself?
Thank you,
Ale
www.alessandrofrancesconi.it _______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
API to parse a saved GIMP's curves file
On 13-09-25 05:21 AM, Alessandro Francesconi wrote:
Im developing a plugin that must read the contents of a GIMP curves file
[snip]
# GIMP curves tool settings
(time 0) (channel value)
(curve
(curve-type smooth)
(n-points 17)
(points 34 0.000000 0.000000 -1.000000 -1.000000 [other X Y points...]) (n-samples 256)
(samples 256 0.000000 0.012218 [other samples...]))
Hm... interesting. Someone chose to save the settings in a format that looks a bit like Scheme code. Unfortunately it isn't Scheme-like enough that you could use the "load" function in a Script-Fu script to load the curve settings via a script and use the contents of the file.
The Procedure browser doesn't list any calls for saving or loading curves. If others thing it would be a worthwhile addition to the API an enhancement request could be find in bugzilla.
Cheers! Kevin. http://www.ve3syb.ca/ |"Nerds make the shiny things that distract Owner of Elecraft K2 #2172 | the mouth-breathers, and that's why we're | powerful!" #include | --Chris Hardwick
API to parse a saved GIMP's curves file
otherwise, you could write your plug-in in Python instead of scheme,
and parse these files
in 15-20 lines of code.
On 26 September 2013 11:48, Kevin Cozens wrote:
On 13-09-25 05:21 AM, Alessandro Francesconi wrote:
I’m developing a plugin that must read the contents of a GIMP “curves” file
[snip]
# GIMP curves tool settings
(time 0) (channel value)
(curve
(curve-type smooth)
(n-points 17)
(points 34 0.000000 0.000000 -1.000000 -1.000000 [other X Y points...])
(n-samples 256)
(samples 256 0.000000 0.012218 [other samples...]))
Hm... interesting. Someone chose to save the settings in a format that looks a bit like Scheme code. Unfortunately it isn't Scheme-like enough that you could use the "load" function in a Script-Fu script to load the curve settings via a script and use the contents of the file.
The Procedure browser doesn't list any calls for saving or loading curves. If others thing it would be a worthwhile addition to the API an enhancement request could be find in bugzilla.
-- Cheers!
Kevin.
http://www.ve3syb.ca/ |"Nerds make the shiny things that distract Owner of Elecraft K2 #2172 | the mouth-breathers, and that's why we're | powerful!" #include | --Chris Hardwick
_______________________________________________ gimp-developer-list mailing list
List address: gimp-developer-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
API to parse a saved GIMP's curves file
(sorry if this appears twice, I only just subscribed)
Kevin Payne writes:
A couple of years ago I wrote a script-fu script to read curve files if that helps:
http://www.gimptalk.com/index.php?/topic/50107-batch-edit-curves/
This works for the exports from GIMP, but GIMP also reads a more compact curve file format, that looks e.g. like this:
# GIMP Curves File 0 22 74 53 121 133 181 197 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 255 31 35 105 107 188 192 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 246 17 1 62 62 126 134 196 202 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 255 26 40 66 63 128 137 198 208 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 255 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 255
The whole file is those 6 lines, which as far as I can test corresponds to the following six curves:
HISTOGRAM-VALUE #(0 22 74 53 121 133 181 197 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 255) HISTOGRAM-RED #(31 35 105 107 188 192 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 246) HISTOGRAM-GREEN #(17 1 62 62 126 134 196 202 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 255) HISTOGRAM-BLUE #(26 40 66 63 128 137 198 208 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 255) HISTOGRAM-ALPHA #(0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 255)
The curves I've downloaded from the web tend to have this format. Should be even easier to parse though.
For my own purposes I've so far just used a stupid awk script that puts curves into a list of lists:
awk '
BEGIN{ print "(" }
/^[0-9 -]+$/{print " ("$0")"} # simple curve file format
/^ *\(points [0-9 .-]+\) *$/ { # GIMP curve settings format
printf " ("
for(i=3;i
Kevin Brubeck Unhammer GPG: 0x766AC60C