PngImagePlugin (version 0.9)
index
/Library/Python/2.7/site-packages/PIL/PngImagePlugin.py

# The Python Imaging Library.
# $Id$
#
# PNG support code
#
# See "PNG (Portable Network Graphics) Specification, version 1.0;
# W3C Recommendation", 1996-10-01, Thomas Boutell (ed.).
#
# history:
# 1996-05-06 fl   Created (couldn't resist it)
# 1996-12-14 fl   Upgraded, added read and verify support (0.2)
# 1996-12-15 fl   Separate PNG stream parser
# 1996-12-29 fl   Added write support, added getchunks
# 1996-12-30 fl   Eliminated circular references in decoder (0.3)
# 1998-07-12 fl   Read/write 16-bit images as mode I (0.4)
# 2001-02-08 fl   Added transparency support (from Zircon) (0.5)
# 2001-04-16 fl   Don't close data source in "open" method (0.6)
# 2004-02-24 fl   Don't even pretend to support interlaced files (0.7)
# 2004-08-31 fl   Do basic sanity check on chunk identifiers (0.8)
# 2004-09-20 fl   Added PngInfo chunk container
# 2004-12-18 fl   Added DPI read support (based on code by Niki Spahiev)
# 2008-08-13 fl   Added tRNS support for RGB images
# 2009-03-06 fl   Support for preserving ICC profiles (by Florian Hoech)
# 2009-03-08 fl   Added zTXT support (from Lowell Alleman)
# 2009-03-29 fl   Read interlaced PNG files (from Conrado Porto Lopes Gouvua)
#
# Copyright (c) 1997-2009 by Secret Labs AB
# Copyright (c) 1996 by Fredrik Lundh
#
# See the README file for information on usage and redistribution.
#

 
Modules
       
Image
ImageFile
ImagePalette
re
string
zlib

 
Classes
       
ImageFile.ImageFile(Image.Image)
PngImageFile
ChunkStream
PngStream
PngInfo

 
class ChunkStream
     Methods defined here:
__init__(self, fp)
call(self, cid, pos, len)
Call the appropriate chunk handler
close(self)
crc(self, cid, data)
Read and verify checksum
crc_skip(self, cid, data)
Read checksum.  Used if the C module is not present
push(self, cid, pos, len)
read(self)
Fetch a new chunk. Returns header information.
verify(self, endchunk='IEND')

 
class PngImageFile(ImageFile.ImageFile)
    
Method resolution order:
PngImageFile
ImageFile.ImageFile
Image.Image

Methods defined here:
load_end(self)
internal: finished reading image data
load_prepare(self)
internal: prepare to read PNG file
load_read(self, bytes)
internal: read more image data
verify(self)
Verify PNG file

Data and other attributes defined here:
format = 'PNG'
format_description = 'Portable network graphics'

Methods inherited from ImageFile.ImageFile:
__init__(self, fp=None, filename=None)
draft(self, mode, size)
Set draft mode
load(self)
Load image data based on tile list

Methods inherited from Image.Image:
__getattr__(self, name)
__repr__(self)
convert(self, mode=None, data=None, dither=None, palette=0, colors=256)
Convert to other pixel format
copy(self)
Copy raster data
crop(self, box=None)
Crop region from image
filter(self, filter)
Apply environment filter to image
fromstring(self, data, decoder_name='raw', *args)
Load data to image from binary string
getbands(self)
Get band names
getbbox(self)
Get bounding box of actual data (non-zero pixels) in image
getcolors(self, maxcolors=256)
Get colors from image, up to given limit
getdata(self, band=None)
Get image data as sequence object.
getextrema(self)
Get min/max value
getim(self)
Get PyCObject pointer to internal image memory
getpalette(self)
Get palette contents.
getpixel(self, xy)
Get pixel value
getprojection(self)
Get projection to x and y axes
histogram(self, mask=None, extrema=None)
Take histogram of image
offset(self, xoffset, yoffset=None)
(deprecated) Offset image in horizontal and/or vertical direction
paste(self, im, box=None, mask=None)
Paste other image into region
point(self, lut, mode=None)
Map image through lookup table
putalpha(self, alpha)
Set alpha layer
putdata(self, data, scale=1.0, offset=0.0)
Put data from a sequence object into an image.
putpalette(self, data, rawmode='RGB')
Put palette data into an image.
putpixel(self, xy, value)
Set pixel value
quantize(self, colors=256, method=0, kmeans=0, palette=None)
resize(self, size, resample=0)
Resize image
rotate(self, angle, resample=0, expand=0)
Rotate image.  Angle given as degrees counter-clockwise.
save(self, fp, format=None, **params)
Save image to file or stream
seek(self, frame)
Seek to given frame in sequence file
show(self, title=None, command=None)
Display image (for debug purposes only)
split(self)
Split image into bands
tell(self)
Return current frame number
thumbnail(self, size, resample=0)
Create thumbnail representation (modifies image in place)
tobitmap(self, name='image')
Return image as an XBM bitmap
tostring(self, encoder_name='raw', *args)
Return image as a binary string
transform(self, size, method, data=None, resample=0, fill=1)
Transform image
transpose(self, method)
Transpose image (flip or rotate in 90 degree steps)

 
class PngInfo
     Methods defined here:
__init__(self)
add(self, cid, data)
add_text(self, key, value, zip=0)

 
class PngStream(ChunkStream)
     Methods defined here:
__init__(self, fp)
chunk_IDAT(self, pos, len)
chunk_IEND(self, pos, len)
chunk_IHDR(self, pos, len)
chunk_PLTE(self, pos, len)
chunk_gAMA(self, pos, len)
chunk_iCCP(self, pos, len)
chunk_pHYs(self, pos, len)
chunk_tEXt(self, pos, len)
chunk_tRNS(self, pos, len)
chunk_zTXt(self, pos, len)

Methods inherited from ChunkStream:
call(self, cid, pos, len)
Call the appropriate chunk handler
close(self)
crc(self, cid, data)
Read and verify checksum
crc_skip(self, cid, data)
Read checksum.  Used if the C module is not present
push(self, cid, pos, len)
read(self)
Fetch a new chunk. Returns header information.
verify(self, endchunk='IEND')

 
Functions
       
getchunks(im, **params)
Return a list of PNG chunks representing this image.
i16(c)
i32(c)
is_cid = match(...)
match(string[, pos[, endpos]]) --> match object or None.
Matches zero or more characters at the beginning of the string
o16(i)
o32(i)
putchunk(fp, cid, *data)
Write a PNG chunk (including CRC field)

 
Data
        __version__ = '0.9'