How Canvas `getImageData` Pixel Sampling Converts RGB to HEX and HSL
Trace the exact 8-bit integer coordinate lookup and mathematical conversion between sRGB channels and cylindrical HSL values.
Primary Browser Tool
Image Color Picker
Inspect any pixel color directly from an image, copy HEX, RGB, and HSL codes, and sample dominant colors.
Zero-Guesswork Coordinate Mapping
Drawing the uploaded image onto a 2D backing canvas populates a flat `Uint8ClampedArray` storing `[R, G, B, A]` quads for every `(x, y)` pixel at offset `(y * width + x) * 4`. Converting `[R, G, B]` produces `#RRGGBB` hex bytes directly and maps chromaticity + lightness cleanly into 0–360° Hue, Saturation %, and Lightness %.
Practical Examples
Translating RGB(37, 99, 235)
Converts cleanly to `#2563EB` and `hsl(221, 83%, 53%)`—matching Tailwind/CSS notation.
Common Mistakes & Honest Limitations
Mistakes to Avoid
- Confusing premultiplied CSS background opacity with raw RGB foreground color.
Technical Limitations
- Transparent pixels (`alpha < 255`) also expose an alpha ratio indicator alongside raw RGB values.