Skip to content

Support HSV and step segments when reading GIMP gradients - #10669

Merged
radarhere merged 2 commits into
python-pillow:mainfrom
siddesh-nexus:gimp-gradient-hsv-step
Dec 1, 2026
Merged

radarhere merged 2 commits into
python-pillow:mainfrom
siddesh-nexus:gimp-gradient-hsv-step

Conversation

@siddesh-nexus

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request:

  • GimpGradientFile raised OSError: cannot handle HSV colour space for gradient segments that blend in HSV. 7 of the 78 gradients that come with GIMP use HSV, including "Full saturation spectrum CCW", "Full saturation spectrum CW" and "Pastel Rainbow", so ImagePalette.load() could not read them.
  • HSV segments are now interpolated as in GIMP's gimp_gradient_get_color_at(). Saturation and value change linearly, and the hue goes counter-clockwise (colour type 1) or clockwise (colour type 2). If both ends have the same hue, it goes all the way around, which is how the "Full saturation spectrum" gradients go from red back to red through every hue.
  • GIMP 2.10 added a sixth blending function, step, which is 1 if pos >= middle and 0 otherwise. It raised IndexError: list index out of range, and is now in SEGMENTS.
  • Gradients that only blend in RGB are unchanged: the palettes of the other 71 GIMP gradients are byte-for-byte the same as before.

The tuples in GradientFile.gradient now have the colour type as a seventh item.

🤖 Generated with Claude Code

GimpGradientFile raised OSError for segments coloured in HSV, which 7 of
the 78 gradients included with GIMP use, and IndexError for the step
blending function added in GIMP 2.10. Interpolate the hue
counter-clockwise or clockwise as GIMP does, and add the step function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@radarhere radarhere added the 🤖-assisted AI-assisted label Nov 30, 2026
@radarhere
radarhere force-pushed the gimp-gradient-hsv-step branch from 9538996 to da5f4d7 Compare December 1, 2026 03:17
@radarhere
radarhere force-pushed the gimp-gradient-hsv-step branch from da5f4d7 to 29ebbe9 Compare December 1, 2026 03:20
@radarhere
radarhere merged commit 27c7ab1 into python-pillow:main Dec 1, 2026
58 checks passed
@radarhere

Copy link
Copy Markdown
Member

For future reference, there is a specification at https://developer.gimp.org/core/standards/ggr/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants