Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Image.putpalette(Colors)?

5 views
Skip to first unread message

Oliver Albrecht

unread,
May 17, 2005, 7:50:41 AM5/17/05
to
Has somebody a example-script how i can put a other palette to a image?
(after this the image should have similar outlook)


Fredrik Lundh

unread,
May 17, 2005, 10:42:38 AM5/17/05
to pytho...@python.org
Oliver Albrecht wrote:

> Has somebody a example-script how i can put a other palette to a image?

here's one of the first google hits for "PIL putpalette":

http://effbot.org/zone/pil-pseudocolor.htm

> (after this the image should have similar outlook)

similar to what?

</F>

Oliver Albrecht

unread,
May 17, 2005, 2:51:58 PM5/17/05
to
Thanks,
I've read this page.( out of date ?)
http://www.pythonware.com/products/pil/articles/creating-palette-images.htm

Very nicely to become answered from the major author and python genius
highly personally himself :-D

Which I want to do is; convert several "RGB" Images (or "P") with one
specified palette (to "P").
Or this (for "P")pattern; if the Source Image has the exact same colors but
wrong(other) paletteIds, how can i sort this? With List.sort()?
And give each pixel the right paletteId? That is what i mean with similar
image (source"RGB" to destinaton"P").

convert() without "WEB"?

(sry if i've enough experience with python)>=newbie

Oliver Albrecht

unread,
May 17, 2005, 7:55:10 PM5/17/05
to
I mean equal outlook.
Or as other objective: give some Images (which has all same colors but
other palettes) for an Animation the same/one palette and nothings is
changed in their outlook


Oliver Albrecht

unread,
May 18, 2005, 6:31:10 PM5/18/05
to
I think in this Example is an fault
lut has the sequence from "im" but not from "lut.putdata(range(256))"

##Getting the Palette Contents Using Resize/Convert
assert im.mode == "P"

lut = im.resize((256, 1))
lut.putdata(range(256))
lut = im.convert("RGB").getdata()
^^
# lut now contains a sequence of (r, g, b) tuples

0 new messages