<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Helpful, but I'm a little late seeing this, as I just posted about spam.<br>
I've made some progress on this too. <br>
<br>
Lucas wrote:
<blockquote
cite="mid:194b7da00904052033i4660ca21u5d768bcd92f65ad1@mail.gmail.com"
type="cite">
<pre wrap="">Hello,
I think what you have to do instead of img.info is to call img.mode,
this will give you the type of image (RGB, ARGB, P (indexed), etc).
In a 'P' mode image you can make the following:
myimg = im.palette
data = myimg.getdata()
data is a tuple with the following structure:
(mode, str)
mode: is the color mode, eg: RGB, ARGB...
list: is a string that contains the values of the palette colors, once
following each other, and you have to parse it by your own depending
on the mode.
eg:
print data
('RGB', "\x80\x00\x00\x00\x00\x00\x00\x80\x00.....")
The you can decode this with the following code:
decoded = [ord(component) for component in data[1]]
print decoded
[128, 0, 0, 0, 0, 0, 0, 128, 0,...]
because of the mode is RGB the colors of our palette are:
R G B
128, 0, 0
0, 0, 0
0, 128, 0
.....
I hope i was clear enough.
Lucas.
On Sat, Apr 4, 2009 at 9:43 AM, Wayne Watson
<a class="moz-txt-link-rfc2396E"
href="mailto:sierra_mtnview@sbcglobal.net"><sierra_mtnview@sbcglobal.net></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Suppose img is a PIL image. img.palette is then an instance, say, myimg. How
do I display what is in it? mimg.hello_in_there()?
Is the depth contained in the palette? PIL-handbook-2.pdf (1.1.3) has no
PaletteImage description, which is where I would expect to find out about
palette methods. Where other than looking in the PIL would I find a
description? Maybe this is basic Python OOP as a means to find out? Doc?
When I use img.info on various images I see in a program I'm using, I see
this:
# wagon.gif: {'compression': 'raw', 'dpi': (1, 1)}
# sentintel image: {}
# moon_surface.tif: {'compression': 'raw', 'dpi': (1, 1)}
# v....bmp : {'compression': 0}
sentinel image is an image created by the hardware that interfaces with the
software, and is 640x480 by 8-bits. v....bmp is one of the output files from
the h/w that I've saved as bmp. Is there a description somewhere of what
the dictionary output contains? I guess it's sort of obvious, but do other
formats have more?
--
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
The Obama Administration plans to double the production
in solar energy from 1% to 2% of the total energy
supply in the next few years. One nuclear reaction
would do the same. Heard on Bill Wattenburg, KGO-AM
"Less than all cannot satisfy Man." -- William Blake
_______________________________________________
Image-SIG maillist - <a class="moz-txt-link-abbreviated"
href="mailto:Image-SIG@python.org">Image-SIG@python.org</a>
<a class="moz-txt-link-freetext"
href="http://mail.python.org/mailman/listinfo/image-sig">http://mail.python.org/mailman/listinfo/image-sig</a>
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta content="text/html;" http-equiv="Content-Type">
<title>Signature.html</title>
<pre class="moz-signature" cols="76"> Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)<span
style="font-weight: bold;"></span><b><b
style="color: rgb(204, 51, 204);" class="b"><span
style="color: rgb(255, 153, 255);"></span><span
style="font-family: monospace;"></span></b></b><span
style="color: rgb(102, 0, 204);">
"In arithemtic as in politics, the importance of one is
determined by the number of zeros behind it." -- Anon
</span><font class="sqq"><span class="sqq"
style="color: rgb(102, 0, 204);"></span></font></pre>
</div>
</body>
</html>