A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-list/1999-September/009363.html below:

color JPEGs

color JPEGs color JPEGsPaul Barrett Barrett at STScI.Edu
Fri Sep 24 10:17:23 EDT 1999
I'm trying to create a color JPEG from Numeric data.  I used Rob Hooft's
message from earlier this year to get me started.  All of his code
appears to work fine.  The problem appears when I try to save the image,
i.e. img.save('filename.jpg'). I get  the following error message:

IOError: cannot write mode P as JPEG

Can a PIL guru tell me what I'm doing wrong and how to proceed? I've
attached the relevant python code to help.

img = Image.Palette('P', (data.shape[1], data.shape[0]),
data.tostring(), 'raw', 'P')
img.palette = ImagePalette.raw('RGB', string.join(palette, ''))
img.save('filename')

-- Paul






More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4