[lug] gimp suggestions?

Tkil tkil at scrye.com
Mon Jan 16 18:57:06 MST 2006


>>>>> "DS" == D Stimits <stimits at comcast.net> writes:

DS> I'm looking for the most direct way to export, from gimp (or some
DS> other common tool), the RGB or RGBA data from a color image as hex
DS> data. E.G., for red => ff0000, green => 00ff00, blue => 0000ff.
DS> I'm experimenting with some of the file formats which come close,
DS> but for example the xpm format seems to do some encoding. Can
DS> anyone give me an idea of some simple way to take an image and
DS> save it as just RGB/RGBA pixel data in a hex string, with no
DS> compression or other information?

The NetPBM stuff can write out each tuple of RGB stuff (dunno about
RGBA) as decimal numbers, which are easy enough to munge into hex.
'man ppm', look at both the raw output (which is really close to what
you want already, just turn raw binary bytes into two hex digits,
which is a perl one-liner) or the "plain" pure-text format.

And NetPBM can take pretty much any input source and turn it into that
intermediate format.  Doesn't handle gamma, but if you just want the
raw sample values in your input, that should do the trick.

If you can get the source data in PNG format, and have gobs of RAM, I
believe that libpng has calls where you can feed it the compressed
image data and then read it out line-by-line.  With minimal error
handling, you're looking at probably less than 50 lines of code.

t.



More information about the LUG mailing list