Re: Making GIF image twice the size - in memory

2007-03-23 Thread Michele Petrazzo
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


Making GIF image twice the size - in memory

2007-03-22 Thread Miki
Hello All,

I get an image from a web page (via urlopen), and like to make it
twice the size.
I'm trying (using PIL):
 code 
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) # This is probably the problem,
have no idea

image_data = urlopen(url).read()
image_data = double(image_data)
 code 

However I don't get a valid GIF image.

Any ideas?

Thanks,
Miki [EMAIL PROTECTED]
http://pythonwise.blogspot.com

-- 
http://mail.python.org/mailman/listinfo/python-list