Image Module

The Image module provides a class with the same name which isused to represent a PIL image. The module also provides a number of factoryfunctions, including functions to load images from files, and to create newimages.

Examples

The following script loads an image, rotates it 45 degrees, and displays itusing an external viewer (usually xv on Unix, and the paint program onWindows).

Open, rotate, and display an image (using the default viewer)

  1. from PIL import Image
  2. im = Image.open("bride.jpg")
  3. im.rotate(45).show()

The following script creates nice 128x128 thumbnails of all JPEG images in thecurrent directory.

Create thumbnails

  1. from PIL import Image
  2. import glob, os
  3.  
  4. size = 128, 128
  5.  
  6. for infile in glob.glob("*.jpg"):
  7. file, ext = os.path.splitext(infile)
  8. im = Image.open(infile)
  9. im.thumbnail(size)
  10. im.save(file + ".thumbnail", "JPEG")

Functions

  • PIL.Image.open(fp, mode='r')[源代码]
  • Opens and identifies the given image file.

This is a lazy operation; this function identifies the file, butthe file remains open and the actual image data is not read fromthe file until you try to process the data (or call theload() method). Seenew().

参数:

  • fp – A filename (string), pathlib.Path object or a file object.The file object must implement read(),seek(), and tell() methods,and be opened in binary mode.
  • mode – The mode. If given, this argument must be “r”.返回:
    An Image object.
    引发:
    IOError – If the file cannot be found, or the image cannot beopened and identified.

警告

To protect against potential DOS attacks caused by “decompression bombs” (i.e. malicious fileswhich decompress into a huge amount of data and are designed to crash or cause disruption by using upa lot of memory), Pillow will issue a DecompressionBombWarning if the image is over a certainlimit. If desired, the warning can be turned into an error withwarnings.simplefilter('error', Image.DecompressionBombWarning) or suppressed entirely withwarnings.simplefilter('ignore', Image.DecompressionBombWarning). See also the loggingdocumentation to have warnings output to the logging facility instead of stderr.

Image processing

  • PIL.Image.alphacomposite(_im1, im2)[源代码]
  • Alpha composite im2 over im1.

参数:

  • im1 – The first image. Must have mode RGBA.
  • im2 – The second image. Must have mode RGBA, and the same size asthe first image.返回:
    An Image object.
  • PIL.Image.blend(im1, im2, alpha)[源代码]
  • Creates a new image by interpolating between two input images, usinga constant alpha.:
  1. out = image1 * (1.0 - alpha) + image2 * alpha

参数:

  • im1 – The first image.
  • im2 – The second image. Must have the same mode and size asthe first image.
  • alpha – The interpolation alpha factor. If alpha is 0.0, acopy of the first image is returned. If alpha is 1.0, a copy ofthe second image is returned. There are no restrictions on thealpha value. If necessary, the result is clipped to fit intothe allowed output range.返回:
    An Image object.
  • PIL.Image.composite(image1, image2, mask)[源代码]
  • Create composite image by blending images using a transparency mask.

参数:

  • image1 – The first image.
  • image2 – The second image. Must have the same mode andsize as the first image.
  • mask – A mask image. This image can have mode“1”, “L”, or “RGBA”, and must have the same size as theother two images.
  • PIL.Image.eval(image, *args)[源代码]
  • Applies the function (which should take one argument) to each pixelin the given image. If the image has more than one band, the samefunction is applied to each band. Note that the function isevaluated once for each possible pixel value, so you cannot userandom components or other generators.

参数:

  • image – The input image.
  • function – A function object, taking one integer argument.返回:
    An Image object.
  • PIL.Image.merge(mode, bands)[源代码]
  • Merge a set of single band images into a new multiband image.

参数:

  • mode – The mode to use for the output image. See:模式.
  • bands – A sequence containing one single-band image foreach band in the output image. All bands must have thesame size.返回:
    An Image object.

Constructing images

  • PIL.Image.new(mode, size, color=0)[源代码]
  • Creates a new image with the given mode and size.

参数:

  • mode – The mode to use for the new image. See:模式.
  • size – A 2-tuple, containing (width, height) in pixels.
  • color – What color to use for the image. Default is black.If given, this should be a single integer or floating point valuefor single-band modes, and a tuple for multi-band modes (one valueper band). When creating RGB images, you can also use colorstrings as supported by the ImageColor module. If the color isNone, the image is not initialised.返回:
    An Image object.
  • PIL.Image.fromarray(obj, mode=None)[源代码]
  • Creates an image memory from an object exporting the array interface(using the buffer protocol).

If obj is not contiguous, then the tobytes method is calledand frombuffer() is used.

参数:

  • obj – Object with array interface
  • mode – Mode to use (will be determined from type if None)See: 模式.返回:
    An image object.

1.1.6 新版功能.

  • PIL.Image.frombytes(mode, size, data, decoder_name='raw', *args)[源代码]
  • Creates a copy of an image memory from pixel data in a buffer.

In its simplest form, this function takes three arguments(mode, size, and unpacked pixel data).

You can also use any pixel decoder supported by PIL. For moreinformation on available decoders, see the sectionWriting Your Own File Decoder.

Note that this function decodes pixel data only, not entire images.If you have an entire image in a string, wrap it in aBytesIO object, and use open() to loadit.

参数:

  • mode – The image mode. See: 模式.
  • size – The image size.
  • data – A byte buffer containing raw data for the given mode.
  • decoder_name – What decoder to use.
  • args – Additional parameters for the given decoder.返回:
    An Image object.
  • PIL.Image.frombuffer(mode, size, data, decoder_name='raw', *args)[源代码]
  • Creates an image memory referencing pixel data in a byte buffer.

This function is similar to frombytes(), but uses datain the byte buffer, where possible. This means that changes to theoriginal buffer object are reflected in this image). Not all modes canshare memory; supported modes include “L”, “RGBX”, “RGBA”, and “CMYK”.

Note that this function decodes pixel data only, not entire images.If you have an entire image file in a string, wrap it in aBytesIO object, and use open() to load it.

In the current version, the default parameters used for the “raw” decoderdiffers from that used for frombytes(). This is abug, and will probably be fixed in a future release. The current releaseissues a warning if you do this; to disable the warning, you should providethe full set of parameters. See below for details.

参数:

  • mode – The image mode. See: 模式.
  • size – The image size.
  • data – A bytes or other buffer object containing rawdata for the given mode.
  • decoder_name – What decoder to use.
  • args
    Additional parameters for the given decoder. For thedefault encoder (“raw”), it’s recommended that you provide thefull set of parameters:
  1. frombuffer(mode, size, data, "raw", mode, 0, 1)

返回:
An Image object.

1.1.4 新版功能.

Registering plugins

注解

These functions are for use by plugin authors. Application authors canignore them.

  • PIL.Image.registeropen(_id, factory, accept=None)[源代码]
  • Register an image file plugin. This function should not be usedin application code.

参数:

  • id – An image format identifier.
  • factory – An image file factory method.
  • accept – An optional function that can be used to quicklyreject images having another format.
  • PIL.Image.registermime(_id, mimetype)[源代码]
  • Registers an image MIME type. This function should not be usedin application code.

参数:

  • id – An image format identifier.
  • mimetype – The image MIME type for this format.
  • PIL.Image.registersave(_id, driver)[源代码]
  • Registers an image save function. This function should not beused in application code.

参数:

  • id – An image format identifier.
  • driver – A function to save images in this format.
  • PIL.Image.registerextension(_id, extension)[源代码]
  • Registers an image extension. This function should not beused in application code.

参数:

  • id – An image format identifier.
  • extension – An extension used for this format.

The Image Class

  • class PIL.Image.Image[源代码]
  • This class represents an image object. To createImage objects, use the appropriate factoryfunctions. There’s hardly ever any reason to call the Image constructordirectly.

An instance of the Image class has the followingmethods. Unless otherwise stated, all methods return a new instance of theImage class, holding the resulting image.

  • Image.convert(mode=None, matrix=None, dither=None, palette=0, colors=256)[源代码]
  • Returns a converted copy of this image. For the “P” mode, thismethod translates pixels through the palette. If mode isomitted, a mode is chosen so that all information in the imageand the palette can be represented without a palette.

The current version supports all possible conversions between“L”, “RGB” and “CMYK.” The matrix argument only supports “L”and “RGB”.

When translating a color image to black and white (mode “L”),the library uses the ITU-R 601-2 luma transform:

  1. L = R * 299/1000 + G * 587/1000 + B * 114/1000

The default method of converting a greyscale (“L”) or “RGB”image into a bilevel (mode “1”) image uses Floyd-Steinbergdither to approximate the original image luminosity levels. Ifdither is NONE, all non-zero values are set to 255 (white). Touse other thresholds, use the point()method.

参数:

  • mode – The requested mode. See: 模式.
  • matrix – An optional conversion matrix. If given, thisshould be 4- or 12-tuple containing floating point values.
  • dither – Dithering method, used when converting frommode “RGB” to “P” or from “RGB” or “L” to “1”.Available methods are NONE or FLOYDSTEINBERG (default).
  • palette – Palette to use when converting from mode “RGB”to “P”. Available palettes are WEB or ADAPTIVE.
  • colors – Number of colors to use for the ADAPTIVE palette.Defaults to 256.返回类型:
    Image
    返回:
    An Image object.

The following example converts an RGB image (linearly calibrated according toITU-R 709, using the D65 luminant) to the CIE XYZ color space:

  1. rgb2xyz = (
  2. 0.412453, 0.357580, 0.180423, 0,
  3. 0.212671, 0.715160, 0.072169, 0,
  4. 0.019334, 0.119193, 0.950227, 0 )
  5. out = im.convert("RGB", rgb2xyz)
  • Image.copy()[源代码]
  • Copies this image. Use this method if you wish to paste thingsinto an image, but still retain the original.

返回类型:Image返回:An Image object.

  • Image.crop(box=None)[源代码]
  • Returns a rectangular region from this image. The box is a4-tuple defining the left, upper, right, and lower pixelcoordinate.

This is a lazy operation. Changes to the source image may ormay not be reflected in the cropped image. To break theconnection, call the load() method onthe cropped copy.

参数:box – The crop rectangle, as a (left, upper, right, lower)-tuple.返回类型:Image返回:An Image object.

  • Image.draft(mode, size)[源代码]
  • Configures the image file loader so it returns a version of theimage that as closely as possible matches the given mode andsize. For example, you can use this method to convert a colorJPEG to greyscale while loading it, or to extract a 128x192version from a PCD file.

Note that this method modifies the Image objectin place. If the image has already been loaded, this method has noeffect.

参数:

  • mode – The requested mode.
  • size – The requested size.
  • Image.filter(filter)[源代码]
  • Filters this image using the given filter. For a list ofavailable filters, see the ImageFilter module.

参数:filter – Filter kernel.返回:An Image object.

  • Image.getbands()[源代码]
  • Returns a tuple containing the name of each band in this image.For example, getbands on an RGB image returns (“R”, “G”, “B”).

返回:A tuple containing band names.返回类型:tuple

  • Image.getbbox()[源代码]
  • Calculates the bounding box of the non-zero regions in theimage.

返回:The bounding box is returned as a 4-tuple defining theleft, upper, right, and lower pixel coordinate. If the imageis completely empty, this method returns None.

  • Image.getcolors(maxcolors=256)[源代码]
  • Returns a list of colors used in this image.

参数:maxcolors – Maximum number of colors. If this number isexceeded, this method returns None. The default limit is256 colors.返回:An unsorted list of (count, pixel) values.

  • Image.getdata(band=None)[源代码]
  • Returns the contents of this image as a sequence objectcontaining pixel values. The sequence object is flattened, sothat values for line one follow directly after the values ofline zero, and so on.

Note that the sequence object returned by this method is aninternal PIL data type, which only supports certain sequenceoperations. To convert it to an ordinary sequence (e.g. forprinting), use list(im.getdata()).

参数:band – What band to return. The default is to returnall bands. To return a single band, pass in the indexvalue (e.g. 0 to get the “R” band from an “RGB” image).返回:A sequence-like object.

  • Image.getextrema()[源代码]
  • Gets the the minimum and maximum pixel values for each band inthe image.

返回:For a single-band image, a 2-tuple containing theminimum and maximum pixel value. For a multi-band image,a tuple containing one 2-tuple for each band.

  • Image.getpalette()[源代码]
  • Returns the image palette as a list.

返回:A list of color values [r, g, b, …], or None if theimage has no palette.

  • Image.getpixel(xy)[源代码]
  • Returns the pixel value at a given position.

参数:xy – The coordinate, given as (x, y).返回:The pixel value. If the image is a multi-layer image,this method returns a tuple.

  • Image.histogram(mask=None, extrema=None)[源代码]
  • Returns a histogram for the image. The histogram is returned asa list of pixel counts, one for each pixel value in the sourceimage. If the image has more than one band, the histograms forall bands are concatenated (for example, the histogram for an“RGB” image contains 768 values).

A bilevel image (mode “1”) is treated as a greyscale (“L”) imageby this method.

If a mask is provided, the method returns a histogram for thoseparts of the image where the mask image is non-zero. The maskimage must have the same size as the image, and be either abi-level image (mode “1”) or a greyscale image (“L”).

参数:mask – An optional mask.返回:A list containing pixel counts.

  • Image.paste(im, box=None, mask=None)[源代码]
  • Pastes another image into this image. The box argument is eithera 2-tuple giving the upper left corner, a 4-tuple defining theleft, upper, right, and lower pixel coordinate, or None (same as(0, 0)). If a 4-tuple is given, the size of the pasted imagemust match the size of the region.

If the modes don’t match, the pasted image is converted to the mode ofthis image (see the convert() method fordetails).

Instead of an image, the source can be a integer or tuplecontaining pixel values. The method then fills the regionwith the given color. When creating RGB images, you canalso use color strings as supported by the ImageColor module.

If a mask is given, this method updates only the regionsindicated by the mask. You can use either “1”, “L” or “RGBA”images (in the latter case, the alpha band is used as mask).Where the mask is 255, the given image is copied as is. Wherethe mask is 0, the current value is preserved. Intermediatevalues will mix the two images together, including their alphachannels if they have them.

See alpha_composite() if you want tocombine images with respect to their alpha channels.

参数:

  • im – Source image or pixel value (integer or tuple).
  • box
    An optional 4-tuple giving the region to paste into.If a 2-tuple is used instead, it’s treated as the upper leftcorner. If omitted or None, the source is pasted into theupper left corner.

If an image is given as the second argument and there is nothird, the box defaults to (0, 0), and the second argumentis interpreted as a mask image.

  • mask – An optional mask image.
  • Image.point(lut, mode=None)[源代码]
  • Maps this image through a lookup table or function.

参数:

  • lut – A lookup table, containing 256 (or 65336 ifself.mode==”I” and mode == “L”) values per band in theimage. A function can be used instead, it should take asingle argument. The function is called once for eachpossible pixel value, and the resulting table is applied toall bands of the image.
  • mode – Output mode (default is same as input). In thecurrent version, this can only be used if the source imagehas mode “L” or “P”, and the output has mode “1” or thesource image mode is “I” and the output mode is “L”.返回:
    An Image object.
  • Image.putalpha(alpha)[源代码]
  • Adds or replaces the alpha layer in this image. If the imagedoes not have an alpha layer, it’s converted to “LA” or “RGBA”.The new layer must be either “L” or “1”.

参数:alpha – The new alpha layer. This can either be an “L” or “1”image having the same size as this image, or an integer orother color value.

  • Image.putdata(data, scale=1.0, offset=0.0)[源代码]
  • Copies pixel data to this image. This method copies data from asequence object into the image, starting at the upper leftcorner (0, 0), and continuing until either the image or thesequence ends. The scale and offset values are used to adjustthe sequence values: pixel = value*scale + offset.

参数:

  • data – A sequence object.
  • scale – An optional scale value. The default is 1.0.
  • offset – An optional offset value. The default is 0.0.
  • Image.putpalette(data, rawmode='RGB')[源代码]
  • Attaches a palette to this image. The image must be a “P” or“L” image, and the palette sequence must contain 768 integervalues, where each group of three values represent the red,green, and blue values for the corresponding pixelindex. Instead of an integer sequence, you can use an 8-bitstring.

参数:data – A palette sequence (either a list or a string).

  • Image.putpixel(xy, value)[源代码]
  • Modifies the pixel at the given position. The color is given asa single numerical value for single-band images, and a tuple formulti-band images.

Note that this method is relatively slow. For more extensive changes,use paste() or the ImageDrawmodule instead.

See:

参数:

  • xy – The pixel coordinate, given as (x, y).
  • value – The pixel value.
  • Image.quantize(colors=256, method=None, kmeans=0, palette=None)[源代码]
  • Convert the image to ‘P’ mode with the specified numberof colors.

参数:

  • colors – The desired number of colors, <= 256
  • method – 0 = median cut1 = maximum coverage2 = fast octree
  • kmeans – Integer
  • palette – Quantize to the PIL.ImagingPalette palette.返回:
    A new image
  • Image.resize(size, resample=0)[源代码]
  • Returns a resized copy of this image.

参数:

  • size – The requested size in pixels, as a 2-tuple:(width, height).
  • resample – An optional resampling filter. This can beone of PIL.Image.NEAREST (use nearest neighbour),PIL.Image.BILINEAR (linear interpolation),PIL.Image.BICUBIC (cubic spline interpolation), orPIL.Image.LANCZOS (a high-quality downsampling filter).If omitted, or if the image has mode “1” or “P”, it isset PIL.Image.NEAREST.返回:
    An Image object.
  • Image.rotate(angle, resample=0, expand=0)[源代码]
  • Returns a rotated copy of this image. This method returns acopy of this image, rotated the given number of degrees counterclockwise around its centre.

参数:

  • angle – In degrees counter clockwise.
  • resample – An optional resampling filter. This can beone of PIL.Image.NEAREST (use nearest neighbour),PIL.Image.BILINEAR (linear interpolation in a 2x2environment), or PIL.Image.BICUBIC(cubic spline interpolation in a 4x4 environment).If omitted, or if the image has mode “1” or “P”, it isset PIL.Image.NEAREST.
  • expand – Optional expansion flag. If true, expands the outputimage to make it large enough to hold the entire rotated image.If false or omitted, make the output image the same size as theinput image.返回:
    An Image object.
  • Image.save(fp, format=None, **params)[源代码]
  • Saves this image under the given filename. If no format isspecified, the format to use is determined from the filenameextension, if possible.

Keyword options can be used to provide additional instructionsto the writer. If a writer doesn’t recognise an option, it issilently ignored. The available options are described in theimage format documentation for each writer.

You can use a file object instead of a filename. In this case,you must always specify the format. The file object mustimplement the seek, tell, and writemethods, and be opened in binary mode.

参数:

  • fp – A filename (string), pathlib.Path object or file object.
  • format – Optional format override. If omitted, theformat to use is determined from the filename extension.If a file object was used instead of a filename, thisparameter should always be used.
  • options – Extra parameters to the image writer.返回:
    None
    引发:
  • KeyError – If the output format could not be determinedfrom the file name. Use the format option to solve this.
  • IOError – If the file could not be written. The filemay have been created, and may contain partial data.
  • Image.seek(frame)[源代码]
  • Seeks to the given frame in this sequence file. If you seekbeyond the end of the sequence, the method raises anEOFError exception. When a sequence file is opened, thelibrary automatically seeks to frame 0.

Note that in the current version of the library, most sequenceformats only allows you to seek to the next frame.

See tell().

参数:frame – Frame number, starting at 0.引发:EOFError – If the call attempts to seek beyond the endof the sequence.

  • Image.show(title=None, command=None)[源代码]
  • Displays this image. This method is mainly intended fordebugging purposes.

On Unix platforms, this method saves the image to a temporaryPPM file, and calls either the xv utility or the displayutility, depending on which one can be found.

On OS X, this method saves the image to a temporary BMP file, and opensit with the native Preview application.

On Windows, it saves the image to a temporary BMP file, and usesthe standard BMP display utility to show it (usually Paint).

参数:

  • title – Optional title to use for the image window,where possible.
  • command – command used to show the image
  • Image.split()[源代码]
  • Split this image into individual bands. This method returns atuple of individual image bands from an image. For example,splitting an “RGB” image creates three new images eachcontaining a copy of one of the original bands (red, green,blue).

返回:A tuple containing bands.

返回:Frame number, starting with 0.

  • Image.thumbnail(size, resample=3)[源代码]
  • Make this image into a thumbnail. This method modifies theimage to contain a thumbnail version of itself, no larger thanthe given size. This method calculates an appropriate thumbnailsize to preserve the aspect of the image, calls thedraft() method to configure the file reader(where applicable), and finally resizes the image.

Note that this function modifies the Imageobject in place. If you need to use the full resolution image as well,apply this method to a copy() of the originalimage.

参数:

  • size – Requested size.
  • resample – Optional resampling filter. This can be oneof PIL.Image.NEAREST, PIL.Image.BILINEAR,PIL.Image.BICUBIC, or PIL.Image.LANCZOS.If omitted, it defaults to PIL.Image.BICUBIC.(was PIL.Image.NEAREST prior to version 2.5.0)返回:
    None
  • Image.tobitmap(name='image')[源代码]
  • Returns the image converted to an X11 bitmap.

注解

This method only works for mode “1” images.

参数:name – The name prefix to use for the bitmap variables.返回:A string containing an X11 bitmap.引发:ValueError – If the mode is not “1”

  • Image.tobytes(encoder_name='raw', *args)[源代码]
  • Return image as a bytes object.

警告

This method returns the raw image data from the internalstorage. For compressed image data (e.g. PNG, JPEG) usesave(), with a BytesIO parameter for in-memorydata.

参数:

  • encoder_name – What encoder to use. The default is touse the standard “raw” encoder.
  • args – Extra arguments to the encoder.返回类型:
    A bytes object.
  • Image.transform(size, method, data=None, resample=0, fill=1)[源代码]
  • Transforms this image. This method creates a new image with thegiven size, and the same mode as the original, and copies datato the new image using the given transform.

参数:

  • size – The output size.
  • method – The transformation method. This is one ofPIL.Image.EXTENT (cut out a rectangular subregion),PIL.Image.AFFINE (affine transform),PIL.Image.PERSPECTIVE (perspective transform),PIL.Image.QUAD (map a quadrilateral to a rectangle), orPIL.Image.MESH (map a number of source quadrilateralsin one operation).
  • data – Extra data to the transformation method.
  • resample – Optional resampling filter. It can be one ofPIL.Image.NEAREST (use nearest neighbour),PIL.Image.BILINEAR (linear interpolation in a 2x2environment), or PIL.Image.BICUBIC (cubic splineinterpolation in a 4x4 environment). If omitted, or if the imagehas mode “1” or “P”, it is set to PIL.Image.NEAREST.返回:
    An Image object.
  • Image.transpose(method)[源代码]
  • Transpose image (flip or rotate in 90 degree steps)

参数:method – One of PIL.Image.FLIP_LEFT_RIGHT,PIL.Image.FLIP_TOP_BOTTOM, PIL.Image.ROTATE_90,PIL.Image.ROTATE_180, PIL.Image.ROTATE_270 orPIL.Image.TRANSPOSE.返回:Returns a flipped or rotated copy of this image.

  • Image.verify()[源代码]
  • Verifies the contents of a file. For data read from a file, thismethod attempts to determine if the file is broken, withoutactually decoding the image data. If this method finds anyproblems, it raises suitable exceptions. If you need to loadthe image after using this method, you must reopen the imagefile.
  • Image.load()[源代码]
  • Allocates storage for the image and loads the pixel data. Innormal cases, you don’t need to call this method, since theImage class automatically loads an opened image when it isaccessed for the first time. This method will close the fileassociated with the image.

返回:An image access object.返回类型:PixelAccess Class or PIL.PyAccess

  • Image.close()[源代码]
  • Closes the file pointer, if possible.

This operation will destroy the image core and release its memory.The image data will be unusable afterward.

This function is only required to close images that have nothad their file read and closed by theload() method.

Attributes

Instances of the Image class have the following attributes:

  • PIL.Image.format
  • The file format of the source file. For images created by the libraryitself (via a factory function, or by running a method on an existingimage), this attribute is set to None.

Type:string or None

  • PIL.Image.mode
  • Image mode. This is a string specifying the pixel format used by the image.Typical values are “1”, “L”, “RGB”, or “CMYK.” See模式 for a full list.

Type:string

  • PIL.Image.size
  • Image size, in pixels. The size is given as a 2-tuple (width, height).

Type:(width, height)

  • PIL.Image.width
  • Image width, in pixels.

Type:int

  • PIL.Image.height
  • Image height, in pixels.

Type:int

  • PIL.Image.palette
  • Colour palette table, if any. If mode is “P”, this should be an instance ofthe ImagePalette class. Otherwise, it shouldbe set to None.

Type:ImagePalette or None

  • PIL.Image.info
  • A dictionary holding data associated with the image. This dictionary isused by file handlers to pass on various non-image information read fromthe file. See documentation for the various file handlers for details.

Most methods ignore the dictionary when returning new images; since thekeys are not standardized, it’s not possible for a method to know if theoperation affects the dictionary. If you need the information later on,keep a reference to the info dictionary returned from the open method.

Unless noted elsewhere, this dictionary does not affect saving files.

Type:dict