Skip Menu |

This queue is for tickets about the GD CPAN distribution.

Report information
The Basics
Id: 120572
Status: resolved
Priority: 0/
Queue: GD

Owner: RURBAN [...]
Requestors: J2N-FORGET [...]

Bug Information
Severity: Normal
Broken in: 2.56
Fixed in: (no value)

Subject: HSV : Negative values of the hue
Download (untitled) / with headers
text/plain 920b
I have explored HSV values with GD::Simple. The final version of my exploration script is attached to this bug report. It checks 5832 RGB triples, executes a round trip RGB -> HSV -> RGB and compares the initial and final RGB triples. Of course, there will be rounding errors, so the final RGB triple will be a little different from the initial. So I compare the Manhattan distance between the two triples and compare it with a fuzz value. The result is that 340 triples out of 5832 give a distance more than 3. In some cases, the distance is 7. In addition, all these 340 triples involve a negative value of the hue, although according to the POD, it should be in the 0..255 interval. By patching GD::Simple with the attached patch, no triple gives a result distance more than 3. And all HSV values, including the hue, are in the 0..255 interval. In addition, the patch fixes a typo (a copy-paste error) in the POD.
Subject: patch
Download patch
application/octet-stream 723b

Message body not shown because it is not plain text.

text/x-perl 670b
#!/usr/bin/perl # -*- encoding: utf-8; indent-tabs-mode: nil -*- use v5.10; use strict; use warnings; use Carp; use GD::Simple; my $fmt = " %3d" x 10; my $step = 15; my $fuzz = 3; my $neg_fix = 0; for (my $r0 = 0; $r0 <= 255; $r0 += $step) { for (my $g0 = 0; $g0 <= 255; $g0 += $step) { for (my $b0 = 0; $b0 <= 255; $b0 += $step) { my ($h, $s, $v) = GD::Simple->RGBtoHSV($r0, $g0, $b0); my ($r1, $g1, $b1) = GD::Simple->HSVtoRGB($h, $s, $v); my $delta = abs($r1 - $r0) + abs($g1 - $g0) + abs($b1 - $b0); if ($delta > $fuzz) { say sprintf $fmt, $h, $s, $v, $r0, $g0, $b0, $r1, $g1, $b1, $delta; } } } }
Download (untitled) / with headers
text/plain 123b
Thanks, I've converted your script to a test-case. Will be in 2.58 -- Reini Urban

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to