[lug] gimp suggestions?

D. Stimits stimits at comcast.net
Mon Jan 16 19:18:25 MST 2006


Tkil wrote:
>>>>>>"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.

I like the program Evelyn suggested, but the NetPBM might be my fastest 
route. One of these days maybe I'll have to figure out how to write gimp 
plugins so I can use gimp to do this sort of thing based on any file 
format. That might be a worthy BLUG topic if anyone here knows 
how...writing gimp plugins and customizing gimp.

D. Stimits, stimits AT comcast DOT net



More information about the LUG mailing list