- PIL Home
- Python Image Library Intro
- Python Image Library Setup
- Python Image Library Basics
- Python Image Library Hierarchy
- Python Image Library Modules
- Python ImageColor Module
- Python ImageDraw Module
- Python ImageStat Module
- Python ImageTK Module
- Python ImageFile Module
- Python ImageFilter Module
- Python ImageGrab Module
- Python ImageMath Module
- Python - Loading Image
- Python - Rotating Image
- Python - Blurring Image
- Python - Converting Image
- Python - Cropping Image
- Python - Image Thumbnails
- Python - Text on Images
- Python - Multiple Image Copies
- Python - Saving Image As PDF
- Python - Saving Screenshot
- Python - Resizing Image
- Python - Adding Watermark
- Python Image Library Resources
- Python - Quick Guide
- Python - Useful Resources
- Python - Discussion
Python ImageFile Module
ImageFile module
The ImageFile module provides some useful support functions for opening the saving the
ImageFile modules contains single Parser function which is used to decode the image part by part and the methods like feed and close
Importing Image module
from PIL import ImageFile
Image module functions
| ImageFile.Parser() | It creates a parser object which can be used to decode an image piece by piece. |
ImageFile module methods
| method name | Description |
| parserobject.feed(data) | Feed a string of data to the parser. This method may raise an IOError exception. |
| parserobject.close() | Tells the parser to finish decoding. If the parser managed to decode an image, it returns an Image object. Otherwise, this method raises an IOError exception. |
| chord(xy, start, end, fill=None, outline=None) | Draws an chord between the start and end angles,but connects the end points with a straight line. |
| ellipse(xy, fill=None, outline=None) | Draws an ellipse inside the given bounding box. |
| line(xy, fill=None, width=0) | Draws a line between the coordinates in the xy list. |
| pieslice(xy, start, end, fill=None, outline=None) | Same as arc, but also draws straight lines between the end points and the center of the bounding box. |
| point(xy, fill=None) | Draws points (individual pixels) at the given coordinates. |
| rectangle(xy, fill=None, outline=None) | Draws a rectangle.. |
Example
from PIL import ImageFile
fp = open("house.jpg")
p = ImageFile.Parser()
while 1:
s = fp.read(1024)
if not s:
break
p.feed(s)
im = p.close()
im.save("housecopy.jpg")
Advertisements