Miki wrote:
Hello All,
Heelo,
I get an image from a web page (via urlopen), and like to make it
twice the size.
-cut-
However I don't get a valid GIF image.
Your code work well here!
Why you said that the string are invalid?
--code: test_image_double.py
from urllib import urlopen
import Image
from ImageFile import Parser
def double(image_data):
image_parser = Parser()
image_parser.feed(image_data)
im = image_parser.close()
new_size = tuple(map(lambda x: 2 * x, im.size))
new = im.resize(new_size)
return new.tostring(gif, P), new, new_size
url = http://www.google.com/intl/en_ALL/images/logo.gif;
image_data = urlopen(url).read()
image_data, img, new_size = double(image_data)
img_new = Image.fromstring(P, new_size, image_data, gif)
img_new.save(./out1.gif)
img.save(./out2.gif)
print PIL version:, Image.VERSION
-- test
michele:~/tmp$ python test_image_double.py file out1.gif file out2.gif
(552, 220) 49554
PIL version: 1.1.5
out1.gif: GIF image data, version 87a, 552 x 220
out2.gif: GIF image data, version 87a, 552 x 220
michele:~/tmp$
Any ideas?
Forgot to specify that the data aren't in raw format, but to decode it
with the gif encoder?
Thanks,
Ciao,
Michele
--
http://mail.python.org/mailman/listinfo/python-list