I don't really know how to perform this conversion in GIMP or any other
graphics editor. But I can describe the steps, that I believe would get
me what I want:
1) Take an arbitrary icon file (png?) on input.
2) Convert it to a grayscale image. In such image, as I understand, each
pixel represents a shade of gray, from white, to black (say, this means
each pixel is described by a number from 0-255).
3) Now, take this grayscale image, and for each pixel convert this pixel
to a HSL color:
pixel.new_color = HSL (hue(vm_label), saturation(vm_label),
pixel.grayscale_level)
In other words the grayscale level should now be mapped to the HSL
lightness parameter, while the hue/saturation should remain constant,
set according to the VM's label color.
Probably we can skip the #3 point above, and perform the conversion in
one step, such as:
pixel.new_color = HSL (hue(vm_label), saturation(vm_label),
grayscale(pixel.color))
This sounds like a trivial program to write in e.g. python, however one
catch is the we don't want to use any library for parsing the input PNG
file, because this is where the attacker might exploit us. Yeah, I know,
python is considered safe in terms of memory operations, etc, but I
would still prefer not to use some full blown image parsing library and
instead some minimal, hand-written, PNG parser written with speciousness
in mind (extra sanitation of each header field)...
joanna.