On mardi 26 février 2008, Shabda Raaj wrote: > This is the code I am trying and errors I get, > > >>> image = Image.new(mode='RGB', size = (10, 10)) > >>> image.convert('JPG') > > Traceback (most recent call last): > File "<interactive input>", line 1, in ? > File "C:\Python24\Lib\site-packages\PIL\Image.py", line 612, in > convert im = im.convert(mode, dither) > ValueError: conversion from RGB to JPG not supported > > >>> image.convert('jpg') > > Traceback (most recent call last): > File "<interactive input>", line 1, in ? > File "C:\Python24\Lib\site-packages\PIL\Image.py", line 612, in > convert im = im.convert(mode, dither) > ValueError: conversion from RGB to jpg not supported > > > Basically I want to create an image, do some drawing on it and get the > image as byte array. I am obviously missing some basic step, but I > can't figure out what :(
'JPG" is not a valid mode ('RGB', 'RGBA', 'CMYK'... are). To get the image as something near array, use image.getdata() method. To save it as jpeg, just use image.save("myfile.jpg"). -- Frédéric http://www.gbiloba.org _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig