i need to do is modify the image in memory like resizing the image in memory etc ... with out saving it disk as i have to return back the image with out saving it disk
PIL supports the use of StringIO objects being passed in place of file
objects. StringIO objects are binary strings of variable length that are kept
in memory so i saved the image in stringio objects the following code does that
file = StringIO()
image.save(file , "JPEG")
cached_image = file.getvalue()
but i can't apply resize operation on cached_image as it a str object
but i found out that Image.formstrin g(mode, size, data, decoder, parameters) Creates an image memory from pixel data in a string so i did the following
image=Image.fro mstring('P',(12 8,128),cached_i mage,'gif')
but the i got following error shown below can any one tell me what was the error .. or tell me an alternative to modify the image in memory with out saving in disk ..
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1744, in fromstring
im.fromstring(d ata, decoder_name, args)
File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 577, in fromstring
raise ValueError("can not decode image data")
ValueError: cannot decode image data
PIL supports the use of StringIO objects being passed in place of file
objects. StringIO objects are binary strings of variable length that are kept
in memory so i saved the image in stringio objects the following code does that
file = StringIO()
image.save(file , "JPEG")
cached_image = file.getvalue()
but i can't apply resize operation on cached_image as it a str object
but i found out that Image.formstrin g(mode, size, data, decoder, parameters) Creates an image memory from pixel data in a string so i did the following
image=Image.fro mstring('P',(12 8,128),cached_i mage,'gif')
but the i got following error shown below can any one tell me what was the error .. or tell me an alternative to modify the image in memory with out saving in disk ..
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1744, in fromstring
im.fromstring(d ata, decoder_name, args)
File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 577, in fromstring
raise ValueError("can not decode image data")
ValueError: cannot decode image data
Comment