I've just started looking at the PIL module. There doesn't seem to be a
close method. Is that right? I just open the image file, and never need to
close it? 2 25445
Derek Fountain wrote: I've just started looking at the PIL module. There doesn't seem to be a close method. Is that right? I just open the image file, and never need to close it?
PIL works with image objects, not files. It automagically closes the
file when it doesn't need it any more.
If you don't trust PIL, do this:
fp = open(filename, "rb")
im = Image.open(fp) # open from file object
im.load() # make sure PIL has read the data
fp.close()
</F>
> PIL works with image objects, not files. It automagically closes the file when it doesn't need it any more.
Ah, OK. As a Python newbie, it's these details I still need to think through
properly.
If you don't trust PIL, do this:
Oh, I trust it. Really!
Thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark 'Kamikaze' Hughes |
last post by:
In the new Python game I'm developing, I need to crop out individual
tiles from larger tilesets, and maintain transparency. Unfortunately,
I've run into major deficiencies in both Tkinter and PIL (PyGame,
wxPython, PyQt, etc. are not really suitable for this program, for a
number of reasons, and I have zero interest in discussing why right
now).
Since the Tkinter.PhotoImage.copy() method doesn't allow a region
parameter, I have to save...
|
by: Gey-Hong Gweon |
last post by:
Is there a way to copy a PIL image to windows clipboard (as a dib
image or a bitmap, I suppose)?
What I would like to accomplish is to do a fast copy and paste of
images from my python application to a windows application such as
powerpoint. A slower way is to use files, which is what I am doing at
the moment.
Thanks in advance.
|
by: John Carter |
last post by:
Does anyone know how to embed PIL into a py2exe program.
As far as I can tell PIL is not finding its plugins for Image I/O,
they are imported dynamically as required. So I cant load or save
pictures
I tried making a copy of the plugin files to the application
directory, but I've had no luck in making the code see the files
I'd be grateful for any suggestion.
|
by: Will McGugan |
last post by:
Hi,
I'm writing an app that downloads images. It rejects images that are
under a certain size - whithout downloading them completely. I've
implemented this using PIL, by downloading the first K and trying to
create a PIL image with it. PIL raises an exception because the file is
incomplete, but the image object is initialised with the image
dimensions, which is what I need. It actualy works well enough, but I'm
concerened about...
|
by: Jack Wu |
last post by:
Hi
I've spent a good majority of my day trying to figure out how to have
PIL 1.1.5 working on my OSX 10.3.9_PPC machine. I'm still stuck and I
have not gotten anywhere. Could somebody please help me...
I've scoured all the documentation, google, and mailing lists to no
avail. I believe the problem may lay in a jpeglib problem with OSX
10.3.9, or a python paths problem.
| |
by: Jair Trejo |
last post by:
I'm doing some image processing in PIL, and I want to
display the results in a GTK window using PyCairo, so
I create a Cairo image surface from the PIL Image like
this:
mfile = StringIO.StringIO()
final.save(mfile, format="PNG")
ima =
cairo.ImageSurface.create_from_png(mfile)
mfile.close()
|
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 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
for gif image ...
|
by: Poppy |
last post by:
I've put together some code to demonstrate what my goal is though looping
pixel by pixel it's rather slow.
import Image
def check_whitespace():
im = Image.open("\\\\server\\vol\\temp\\image.jpg")
size = im.size
|
by: Silfheed |
last post by:
Heyas
So I've been messing around with the PIL and PNG's and came across a
little problem with PNG's.
So just to clarify, I'm running with the standard ubuntu 8.04 python-
imaging package that installs zlib and all the other goodies that go
along to make the PIL work with PNG's nicely.
So this works fine:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |