Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting Gimp Gradient file

Tags:

gimp

Does anyone know how the Gimp ggr gradient files are interpreted? Some of the included gradients are really nice and I want to reconstruct them. Are there any scripts that can export these gradients to a file with color values or something?

like image 290
Johnny Avatar asked Jan 21 '23 15:01

Johnny


2 Answers

The context menu in GIMP's gradient dialog has two export functions: "Save as POVRay" and "Save as CSS" - the later one might be useful for reuse.

The native GIMP gradient format is a pure-text format, which is self-explanatory to anyone opening the file - so reusing native GIMP files in your own projects would not be hard. It is interesting to note that GIMP gradients have some features that do not exist in other formats, so coding to interpret the files natively might make sense, as opposed as using some other gradient format. The features I can remember are: positioning the middle of the segment, the segment blending functions (that can be sinusoidal or spherical, besides linear) and the use of the dynamic "foreground" and "background" colors in the blend, instead of a fixed color.

Example of GIMP gradient file:

GIMP Gradient
Name: Mexican flag smooth
2
0.000000 0.250000 0.500000 0.000000 1.000000 0.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0 0
0.500000 0.750000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.000000 0.000000 1.000000 0 0

So, this is a file with two segments, and for the first segment we have: starts at position 0, middle at 0.25, ending at 0.5, the left color being RGBA (0,1,0,1) (full opacity green), the right color is RGBA(1,1,1,1) (full opacity white). The other two numbers are one for the Blending function of the segment:

The blending function of the segment { GRADIENT-SEGMENT-LINEAR (0), GRADIENT-SEGMENT-CURVED (1), GRADIENT-SEGMENT-SINE (2), GRADIENT-SEGMENT-SPHERE-INCREASING (3), GRADIENT-SEGMENT-SPHERE-DECREASING (4) }

And the other for the coloring type:

The coloring type of the segment { GRADIENT-SEGMENT-RGB (0), GRADIENT-SEGMENT-HSV-CCW (1), GRADIENT-SEGMENT-HSV-CW (2) }

(I got the enum information from GIMP's procedure browser - at help->Procedure browser, looking at the description of the calls "gimp-gradient-segment-get-coloring-type" and "gimp-gradient-segment-get-blending-function")

like image 54
jsbueno Avatar answered Jan 31 '23 03:01

jsbueno


Here's a Python script that reads them: ggr.py.

like image 24
Ned Batchelder Avatar answered Jan 31 '23 01:01

Ned Batchelder