awips2/pythonPackages/pil/PIL/ImageFileIO.py
root 9bb8decbcf Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: 133dc97f67 [formerly a02aeb236c] [formerly 9f19e3f712] [formerly 06a8b51d6d [formerly 9f19e3f712 [formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]]
Former-commit-id: 06a8b51d6d
Former-commit-id: 377dcd10b9 [formerly 3360eb6c5f]
Former-commit-id: 8e80217e59
2012-01-06 08:55:05 -06:00

47 lines
1.2 KiB
Python

#
# The Python Imaging Library.
# $Id: ImageFileIO.py 2134 2004-10-06 08:55:20Z fredrik $
#
# kludge to get basic ImageFileIO functionality
#
# History:
# 1998-08-06 fl Recreated
#
# Copyright (c) Secret Labs AB 1998-2002.
#
# See the README file for information on usage and redistribution.
#
from StringIO import StringIO
##
# The <b>ImageFileIO</b> module can be used to read an image from a
# socket, or any other stream device.
# <p>
# This module is deprecated. New code should use the <b>Parser</b>
# class in the <a href="imagefile">ImageFile</a> module instead.
#
# @see ImageFile#Parser
class ImageFileIO(StringIO):
##
# Adds buffering to a stream file object, in order to
# provide <b>seek</b> and <b>tell</b> methods required
# by the <b>Image.open</b> method. The stream object must
# implement <b>read</b> and <b>close</b> methods.
#
# @param fp Stream file handle.
# @see Image#open
def __init__(self, fp):
data = fp.read()
StringIO.__init__(self, data)
if __name__ == "__main__":
import Image
fp = open("/images/clenna.im", "rb")
im = Image.open(ImageFileIO(fp))
im.load() # make sure we can read the raster data
print im.mode, im.size