473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Making GIF image twice the size - in memory

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 <mi*********@gmail.com>
http://pythonwise.blogspot.com

Mar 22 '07 #1
1 1473
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
Mar 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Novice | last post by:
I'm afraid I will incur the wraith of Mr. Powell on this one - but I did read his #1 FAQ and some others and I still can't figure this out. I created this little c# app. and I have a PictureBox...
4
by: Sharon | last post by:
Hi Everyone, I have a TIF file 62992 x 113386 Pixels, Huffman RLE compression, 3200 x 3200 DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08 MB (45,169,042 Bytes). This...
12
by: Sharon | last post by:
I’m wrote a small DLL that used the FreeImage.DLL (that can be found at http://www.codeproject.com/bitmap/graphicsuite.asp). I also wrote a small console application in C++ (unmanaged) that uses...
0
by: Mattia | last post by:
************************************************** Manage image without exhausted memory ************************************************** Hi; I have a big problem. I must create a script that...
4
by: LT.Ang | last post by:
I am developing an application that possibly opens very large images - bmp, jpeg, tiff. I have 2 questions: Language: C#, VS .NET 2003. 1. When the program opens a BMP image, the amount of...
6
by: comp.lang.php | last post by:
I have an image that's only 100K in size, and I am working with 8mb of memory. If I do this: print_r(ceil((int)ini_get('memory_limit') * 10 *...
2
by: bizt | last post by:
Hi, Is it possible to obtain the width/ height of an image when that image is dyanically created using a PHP script and passing GET attributes. For example: <img...
3
by: computer_guy | last post by:
Hi Everyone, I run into a problem. I am trying to write an aspx that can dynamically generate an image based on some input parameters. Things are very simple if the size of the parameters is...
1
by: bharathv6 | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.