Re: PIL and swapping colors
Fredrik Lundh <[email protected]>
| Newsgroups | gmane.comp.python.image |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Nov 5, 2010 at 7:16 AM, loz.accs <[email protected]> wrote: > Hi, everyone! > PIL doesn't provide screenshots making on linux, so I wrote > C-extension that uses Imlib2 to grab screenshots in raw RGBA format > and returns it to python interpreter. > > Image object (Image.fromstring) was created successfully, but red and > blue colors was swapped. > So my question: is there any way to swap colors in image using PIL? You can pass in a "raw mode" argument to fromstring/frombuffer that tells PIL what "unpacker" to use: >>> Image.frombuffer("RGBA", (1, 1), "\1\2\3\4", "raw", "RGBA", 0, 1).getpixel((0,0)) (1, 2, 3, 4) >>> Image.frombuffer("RGBA", (1, 1), "\1\2\3\4", "raw", "ABGR", 0, 1).getpixel((0,0)) (4, 3, 2, 1) The default mode is the same as the image mode. > And why don't you make linux version of ImageGrab, based on Imlib2 for example? Lack of round tuits, mostly. Contributions are welcome. </F> _______________________________________________ Image-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/image-sig