473,399 Members | 4,177 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,399 software developers and data experts.

Memory Based File Objects

Hi there,

I am using the Python Image package to do some Image conversion. I
have a "pgm" Image and this must be converted to a "1" Bits / Sample
Tiff Image. There for I am using Image.save ("lala.tiff"). *hm* A Tiff
Image opt. consists of several pages so I am thinking about using the
pytiff package as well. The existing code is like that

parser = ImageFile.Parser ()
parser.feed (imagecontent)
image = parser.close () # Now we have the Image

image = image.convert ("1") # reduce to 1 Bits per sample
image.save ("lala.tif") # Store as Tiff

After everey File has been processed I am using the "tiffcp" command
to append all the files to a single tiff-file containing each image as
a separate page.

eg. "tiffcp fileone.tiff filetwo.tiff filethree.tiff allinone.tiff"

Performance is an issue here and therefore I am evaluating the pytiff
package. Cause this package can reduce to "1" Bits per Sample and
append to tifffiles.

So the code would be like this

image.save (fileobject, format="tif")
tifffile = pytiff.TiffFileReader (fileobject)

# do some stuff

allinone = pytiff.TiffFileWriter ("allinone.tiff")
allinone.append (fifffile)

Of course I dont wanna write the "in between" File to disk with
image.save () I do wann to to use a memory file object. The Image
Documentation says that file object just has to implement seek, tell
and write. Does anybody have an example how to do that or maybe a
snipplet for an "In Memory" File Object with an unknown size.

Kind Regards

Michael
Jul 18 '05 #1
2 5981
Quick reply... check out the StringIO module....

Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

Jul 18 '05 #2
On 22 Feb 2005 02:06:52 -0800, rumours say that mi****************@web.de
(michael) might have written:

<snip of unimportant image manipulation>
The Image
Documentation says that file object just has to implement seek, tell
and write. Does anybody have an example how to do that or maybe a
snipplet for an "In Memory" File Object with an unknown size.


You probably need the StringIO (or cStringIO) module. Check the module
reference.
--
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
Jul 18 '05 #3

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

Similar topics

0
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since...
6
by: Jim Butler | last post by:
Currently we are having to do an iisreset to update a gac component on a web server. Just removing it from the gac and re-adding it does not update the code executing on the server. This is not...
11
by: Shane Suebsahakarn | last post by:
Hi all, This might be one of those things for which there is no workaround. I'm using A2K2, and using it to perform a very large batch ouput. Both the front and back ends are MDB files, so no...
25
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
0
by: domtam | last post by:
Hi everybody, As far as I understand, each worker process in a web garden (say, in IIS 6.0) has its own copy of Cache objects, static objects and Application(state) objects. In other words, they...
18
by: diffuser78 | last post by:
I have a python code which is running on a huge data set. After starting the program the computer becomes unstable and gets very diffucult to even open konsole to kill that process. What I am...
0
by: xievvv | last post by:
We are experiencing a memory leak in one of our applications. It is a web-based reporting system that produces large (> 500mb) PDF reports. It takes approx 4 hours to run the largest of these reports...
17
by: frederic.pica | last post by:
Greets, I've some troubles getting my memory freed by python, how can I force it to release the memory ? I've tried del and gc.collect() with no success. Here is a code sample, parsing an XML...
3
by: crazy420fingers | last post by:
I'm running a python program that simulates a wireless network protocol for a certain number of "frames" (measure of time). I've observed the following: 1. The memory consumption of the program...
34
by: jacob navia | last post by:
Suppose that you have a module that always allocates memory without ever releasing it because the guy that wrote it was lazy, as lazy as me. Now, you want to reuse it in a loop. What do you do?...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.