text: 
  Contents
  BMP¶
  Pillow.
  DIB¶
  Pillow reads and writes DIB files. DIB files are similar to BMP files, so see above for more information.
  New in version 6.0.0.
  EPS¶
  Pillow
  Pillow).
  - transparency
  Transparency color index. This key is omitted if the image is not transparent.
  - version
  Version (either
  GIF87aor
  GIF89a).
  - duration
  May not be present. The time to display the current frame of the GIF, in milliseconds.
  - loop
  May not be present. The number of times the GIF should loop. 0 means that it will loop forever.
  - comment
  May not be present. A comment about the image.
  - extension
  May not be present. Contains application specific information.
  Reading sequences¶
  The GIF loader supports the
  seek() and
  tell() methods. You can combine these methods
  to seek to the next frame (
  im.seek(im.tell() + 1)).
  im.seek() raises an
  EOFError if you try to seek after the last frame.
  Saving¶
  When calling
  save() to write a GIF file, the
  following options are available:
  im.save(out, save_all=True, append_images=[im1, im2, ...])
  - save_all
  If present and true, all frames of the image will be saved. If not, then only the first frame of a multiframe image will be saved.
  - append_images
  A list of images to append as additional frames. Each of the images in the list can be single or multiframe images. This is currently supported for GIF, PDF, TIFF, and WebP.
  It is also supported for ICNS. If images are passed in of relevant sizes, they will be used instead of scaling down the main image.
  - include_color_table
  Whether or not to include local color table.
  - interlace
  Whether or not the image is interlaced. By default, it is, unless the image is less than 16 pixels in width or height.
  - disposal
  Indicates the way in which the graphic is to be treated after being displayed.
  0 - No disposal specified.
  1 - Do not dispose.
  2 - Restore to background color.
  3 - Restore to previous content.
  Pass a single integer for a constant disposal, or a list or tuple to set the disposal for each frame separately.
  - palette
  Use the specified palette for the saved image. The palette should be a bytes or bytearray object containing the palette entries in RGBRGB… form. It should be no more than 768 bytes. Alternately, the palette can be passed in as an
  PIL.ImagePalette.ImagePaletteobject.
  - optimize
  If present and true, attempt to compress the palette by eliminating unused colors. This is only useful if the palette can be compressed to the next smaller power of 2 elements.
  Note that if the image you are saving comes from an existing GIF, it may have
  the following properties in its
  info dictionary.
  For these options, if you do not pass them in, they will default to
  their
  info values.
  - transparency
  Transparency color index.
  - duration
  The display duration of each frame of the multiframe gif, in milliseconds. Pass a single integer for a constant duration, or a list or tuple to set the duration for each frame separately.
  - loop
  Integer number of times the GIF should loop. 0 means that it will loop forever. By default, the image will not loop.
  - comment
  A comment about the image.
  Pillow reads and (macOS only) writes macOS
  )).
  The
  save() method can take the following keyword arguments:
  - append_images
  A list of images to replace the scaled down versions of the image. The order of the images does not matter, as their use is determined by the size of each image.
  New in version 5.1.0.), (256, 256)]. Any sizes bigger than the original size or 256 will be ignored.
  IM¶
  IM is a format used by LabEye and other applications based on the IFUNC image processing library. The library reads and writes most uncompressed interchange versions of this format.
  IM is the only format that can store all internal Pillow formats.
  JPEG¶
  Pillow.
  By default Pillow doesn’t allow loading of truncated JPEG files, set
  ImageFile.LOAD_TRUNCATED_IMAGES to override this..
  - comment
  A comment about the image.
  New in version 7.1.0.
  The
  save() method supports the following options:
  - quality
  The image quality, on a scale from 0 (worst) to 95 (best). The default is 75. Values above 95 should be avoided; 100 disables portions of the JPEG compression algorithm, and results in large files with hardly any gain in image quality.
  - optimize
  If present and true, indicates that the encoder should make an extra pass over the image in order to select optimal encoder settings.
  - progressive
  If present and true, indicates that this image should be stored as a progressive JPEG file.
  - dpi
  A tuple of integers representing the pixel density,
  (x,y).
  - icc_profile
  If present and true,:2:0: Specific sampling values
  -1: equivalent to
  keep
  0: equivalent to
  4:4:4
  1: equivalent to
  4:2:2
  2: equivalent to
  4:2:0
  -.
  Pillow reads and writes JPEG 2000 files containing
  L,
  LA,
  RGB or
  RGBA data. It can also read files containing
  YCbCr data, which it
  converts on read into
  RGB or
  RGBA depending on whether or not there is
  an alpha channel. Pillow supports JPEG 2000 raw codestreams (
  .j2k files),
  as well as boxed JPEG 2000 files (
  .j2p or
  .jpx files). Pillow does
  not support files whose components have different sampling frequencies.
  When loading, if you set the
  mode on the image prior to the
  load() method being invoked, you can ask Pillow Pillow (if
  you fail to do this, you will get errors about not being able to load the
  _imaging DLL).
  MSP¶
  Pillow identifies and reads MSP files from Windows 1 and 2. The library writes uncompressed (Windows 1) versions of this format.
  PNG¶
  Pillow identifies, reads, and writes PNG files containing
  1,
  L,
  LA,
  I,
  P,
  RGB or
  RGBA data. Interlaced files are supported as of
  v1.1.7.
  As of Pillow 6.0, EXIF data can be read from PNG images. However, unlike other
  image formats, EXIF data is not guaranteed to be present in
  info until
  load() has been
  called.
  By default Pillow doesn’t allow loading of truncated PNG files, set
  ImageFile.LOAD_TRUNCATED_IMAGES to override this.
  The
  open() function sets the following
  info properties, when appropriate:
  - chromaticity
  The chromaticity points, as an 8 tuple of floats. (
  White Point X,
  White Point Y,
  Red X,
  Red Y,
  Green X,
  Green Y,
  Blue X,
  Blue Y)
  - gamma
  Gamma, given as a floating point number.
  - srgb
  The sRGB rendering intent as an integer.
  0 Perceptual
  1 Relative Colorimetric
  2 Saturation
  3 Absolute Colorimetric
  - transparency
  For
  Pimages: Either the palette index for full transparent pixels, or a byte string with alpha values for each palette entry.
  For
  1,
  L,
  Iand
  RGBimages, the color that represents full transparent pixels in this image.
  This key is omitted if the image is not a transparent palette image.
  open also sets
  Image.text to a dictionary and true, instructs the PNG writer to make the output file as small as possible. This includes extra processing in order to find optimal encoder settings.
  - transparency
  For
  P,
  1,
  L,
  I, and
  RGBimages, this option controls what color from the chunks.
  -.
  - exif
  The exif data to include in the saved file.
  New in version 6.0.0.
  -.
  APNG sequences¶
  The PNG loader includes limited support for reading and writing Animated Portable
  Network Graphics (APNG) files.
  When an APNG file is loaded,
  get_format_mimetype()
  will return
  "image/apng". The value of the
  is_animated
  property will be
  True when the
  n_frames property is
  greater than 1. For APNG files, the
  n_frames property depends on both the animation
  frame count as well as the presence or absence of a default image. See the
  default_image property documentation below for more details.
  The
  seek() and
  tell() methods
  are supported.
  im.seek() raises an
  EOFError if you try to seek after the last frame.
  These
  info properties will be set for APNG frames,
  where applicable:
  - default_image
  Specifies whether or not this APNG file contains a separate default image, which is not a part of the actual APNG animation.
  When an APNG file contains a default image, the initially loaded image (i.e. the result of
  seek(0)) will be the default image. To account for the presence of the default image, the
  n_framesproperty will be set to
  frame_count + 1, where
  frame_countis the actual APNG animation frame count. To load the first APNG animation frame,
  seek(1)must be called.
  True- The APNG contains default image, which is not an animation frame.
  False- The APNG does not contain a default image. The
  n_framesproperty will be set to the actual APNG animation frame count. The initially loaded image (i.e.
  seek(0)) will be the first APNG animation frame.
  - loop
  The number of times to loop this APNG, 0 indicates infinite looping.
  - duration
  The time to display this APNG frame (in milliseconds).
  Note
  The APNG loader returns images the same size as the APNG file’s logical screen size. The returned image contains the pixel data for a given frame, after applying any APNG frame disposal and frame blend operations (i.e. it contains what a web browser would render for this frame - the composite of all previous frames and this frame).
  Any APNG file containing sequence errors is treated as an invalid image. The APNG loader will not attempt to repair and reorder files containing sequence errors.
  Saving¶
  When calling
  save(), by default only a single frame PNG file
  will be saved. To save an APNG file (including a single frame APNG), the
  save_all
  parameter must be set to
  True. The following parameters can also be set:
  - default_image
  Boolean value, specifying whether or not the base image is a default image. If
  True, the base image will be used as the default image, and the first image from the
  append_imagessequence will be the first APNG animation frame. If
  False, the base image will be used as the first APNG animation frame. Defaults to
  False.
  - append_images
  A list or tuple of images to append as additional frames. Each of the images in the list can be single or multiframe images. The size of each frame should match the size of the base image. Also note that if a frame’s mode does not match that of the base image, the frame will be converted to the base image mode.
  - loop
  Integer number of times to loop this APNG, 0 indicates infinite looping. Defaults to 0.
  - duration
  Integer (or list or tuple of integers) length of time to display this APNG frame (in milliseconds). Defaults to 0.
  - disposal
  An integer (or list or tuple of integers) specifying the APNG disposal operation to be used for this frame before rendering the next frame. Defaults to 0.
  0 (
  APNG_DISPOSE_OP_NONE, default) - No disposal is done on this frame before rendering the next frame.
  1 (
  PIL.PngImagePlugin.APNG_DISPOSE_OP_BACKGROUND) - This frame’s modified region is cleared to fully transparent black before rendering the next frame.
  2 (
  APNG_DISPOSE_OP_PREVIOUS) - This frame’s modified region is reverted to the previous frame’s contents before rendering the next frame.
  - blend
  An integer (or list or tuple of integers) specifying the APNG blend operation to be used for this frame before rendering the next frame. Defaults to 0.
  0 (
  APNG_BLEND_OP_SOURCE) - All color components of this frame, including alpha, overwrite the previous output image contents.
  1 (
  APNG_BLEND_OP_OVER) - This frame should be alpha composited with the previous output image contents.
  Note
  The
  duration,
  disposal and
  blend parameters can be set to lists or tuples to
  specify values for each individual frame in the animation. The length of the list or tuple
  must be identical to the total number of actual frames in the APNG animation.
  If the APNG contains a default image (i.e.
  default_image is set to
  True),
  these list or tuple parameters should not include an entry for the default image.
  SPIDER¶
  Pillow reads and writes SPIDER image files of 32-bit floating point data (“F;32F”).
  Pillow also reads SPIDER stack files containing sequences of SPIDER images. The
  seek() and
  tell() methods are supported, and
  random access is allowed.
  The
  open() method sets the following attributes:
  - format
  Set to
  SPIDER
  - istack
  Set to 1 if the file is an image stack, else 0.
  - n_framesGA¶
  Pillow reads and writes TGA images containing
  L,
  LA,
  P,
  RGB, and
  RGBA data. Pillow can read and write both uncompressed and
  run-length encoded TGAs.
  TIFF¶
  Pillow reads and writes TIFF files. It can read both striped and tiled images, pixel and plane interleaved multi-band images. If you have libtiff and its headers installed, Pillow can read and write many kinds of compressed TIFF files. If not, Pillow will only read and write uncompressed files.
  Note
  Beginning in version 5.0.0, Pillow requires libtiff to read or write compressed files. Prior to that release, Pillow had buggy support for reading Packbits, LZW and JPEG compressed TIFFs without using libtiff.
  TiffTags.
  Reading Multi-frame TIFF Images¶
  The TIFF loader supports the
  seek() and
  tell() methods, taking and returning frame numbers
  within the image file. You can combine these methods to seek to the next frame
  (
  im.seek(im.tell() + 1)). Frames are numbered from 0 to
  im.num_frames - 1,
  and can be accessed in any order.
  im.seek() raises an
  EOFError if you try to seek after the
  last frame.
  Saving Tiff Images¶
  The
  save() method can take the following keyword arguments:
  - save_all
  If true, Pillow will save all frames of the image to a multiframe tiff document.
  New in version 3.4.0.
  - append_images
  A list of images to append as additional frames. Each of the images in the list can be single or multiframe images. Note however, that for correct results, all the appended images should have the same
  encoderinfoand
  encoderconfigproperties.
  New in version 4.2.0.
  - 5.4.0.
  Previous versions only supported some tags when writing using libtiff. The supported list is found in
  TiffTags.LIBTIFF_CORE.
  New in version 6.1.0.
  Added support for signed types (e.g.
  TIFF_SIGNED_LONG) and multiple values. Multiple values for a single tag must be to
  ImageFileDirectory_v2as a tuple and require a matching type in
  tagtypetagtype.
  -"
  - quality
  The image quality for JPEG compression, on a scale from 0 (worst) to 100 (best). The default is 75.
  New in version 6.1.0.
  These arguments to set the tiff header fields are an alternative to using the general tags available through tiffinfo.
  description
  software
  date_time
  artist
  Strings
  - resolution_unit
  An integer. 1 for no unit, 2 for inches and 3 for centimeters.
  - resolution
  Either an integer or a float, used for both the x and y resolution.
  - x_resolution
  Either an integer or a float.
  - y_resolution
  Either an integer or a float.
  - dpi
  A tuple of (x_resolution, y_resolution), with inches as the resolution unit. For consistency with other image formats, the x and y resolutions of the dpi will be rounded to the nearest integer.
  WebP¶
  Pillow reads and writes WebP files. The specifics of Pillow’s capabilities with this format are currently undocumented.
  The
  save() method supports the following options:
  - lossless
  If present and true, instructs the WebP writer to use lossless compression.
  - quality
  Integer, 1-100, Defaults to 80. For lossy, 0 gives the smallest size and 100 the largest. For lossless, this parameter is the amount of effort put into the compression: 0 is the fastest, but gives larger files compared to the slowest, but best, 100.
  - method
  Quality/speed trade-off (0=fast, 6=slower-better). Defaults to 0.
  - icc_profile.
  Saving sequences¶
  Note
  Support for animated WebP files will only be enabled if the system WebP
  library is v0.5.0 or later. You can check webp animation support at
  runtime by calling
  features.check("webp_anim").
  When calling
  save() to write a WebP file, the
  following options are available when the
  save_all argument is present and
  true.
  - append_images
  A list of images to append as additional frames. Each of the images in the list can be single or multiframe images.
  - duration
  The display duration of each frame, in milliseconds. Pass a single integer for a constant duration, or a list or tuple to set the duration for each frame separately.
  - loop
  Number of times to repeat the animation. Defaults to [0 = infinite].
  - background
  Background color of the canvas, as an RGBA tuple with values in the range of (0-255).
  - minimize_size
  If true, minimize the output size (slow). Implicitly disables key-frame insertion.
  - kmin, kmax
  Minimum and maximum distance between consecutive key frames in the output. The library may insert some key frames as needed to satisfy this criteria. Note that these conditions should hold: kmax > kmin and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then key-frame insertion is disabled; and if kmax == 1, then all frames will be key-frames (kmin value does not matter for these special cases).
  - allow_mixed
  If true, use mixed compression mode; the encoder heuristically chooses between lossy and lossless for each frame.
  Read-only formats¶
  BLP¶
  BLP is the Blizzard Mipmap Format, a texture format used in World of
  Warcraft. Pillow supports reading
  JPEG Compressed or raw
  BLP1
  images, and all types of
  BLP2 images., uncompressed RGB data and DXT1, DXT3, and DXT5 pixel formats are
  supported, and only in
  RGBA mode.
  New in version 3.4.0: DXT3
  FLI, FLC¶
  Pillow reads Autodesk FLI and FLC animations.
  The
  open() method sets the following
  info properties:
  - duration
  The delay (in milliseconds) between each frame.
  FPX¶
  Pillow
  Pillow reads uncompressed GD2 files. Note that you must use
  PIL.GdImageFile.open() to read such a file.
  The
  open() method sets the following
  info properties:
  - transparency
  Transparency color index. This key is omitted if the image is not transparent.
  MIC¶
  Pillow identifies and reads Microsoft Image Composer (MIC) files. When opened,
  the first sprite in the file is loaded. You can use
  seek() and
  tell() to read other sprites from the file.
  Note that there may be an embedded gamma of 2.2 in MIC files.
  MPO¶
  Pillow identifies and reads Multi Picture Object (MPO) files, loading the primary
  image when first opened. The
  seek() and
  tell()
  methods may be used to read other pictures from the file. The pictures are
  zero-indexed and random access is supported.
  PCD¶
  Pillow reads PhotoCD files containing
  RGB data. This only reads the 768x512
  resolution image from the file. Higher resolutions are encoded in a proprietary
  encoding.
  PIXAR¶
  Pillow provides limited support for PIXAR raster files. The library can identify and read “dumped” RGB files.
  The format code is
  PIXAR.
  WAL¶
  New in version 1.1.4.
  Pillow.
  WMF¶
  Pillow can identify WMF files.
  On Windows, it can read WMF files. By default, it will load the image at 72 dpi. To load it at another resolution:
  from PIL import Image with Image.open("drawing.wmf") as im: im.load(dpi=144)
  To add other read or write support,")
  Write-only formats¶
  PALM¶
  Pillow provides write-only support for PALM pixmap files.
  The format code is
  Palm, the extension is
  .palm.
  PDF¶
  Pillow can write PDF (Acrobat) images. Such images are written as binary PDF 1.4 files, using either JPEG or HEX encoding depending on the image mode (and whether JPEG support is available or not).
  The
  save() method can take the following keyword arguments:
  - save_all
  If a multiframe image is used, by default, only the first image will be saved. To save all frames, each frame to a separate page of the PDF, the
  save_allparameter must be present and set to
  True.
  New in version 3.0.0.
  - append_images
  A list of images to append as additional pages. Each of the images in the list can be single or multiframe images.
  New in version 4.2.0.
  - append
  Set to True to append pages to an existing PDF file. If the file doesn’t exist, an
  OSErrorwill be raised.
  New in version 5.1.0.
  - resolution
  Image resolution in DPI. This, together with the number of pixels in the image, will determine the physical dimensions of the page that will be saved in the PDF.
  - title
  The document’s title. If not appending to an existing PDF file, this will default to the filename.
  New in version 5.1.0.
  - author
  The name of the person who created the document.
  New in version 5.1.0.
  - subject
  The subject of the document.
  New in version 5.1.0.
  - keywords
  Keywords associated with the document.
  New in version 5.1.0.
  - creator
  If the document was converted to PDF from another format, the name of the conforming product that created the original document from which it was converted.
  New in version 5.1.0.
  - producer
  If the document was converted to PDF from another format, the name of the conforming product that converted it to PDF.
  New in version 5.1.0.
  - creationDate
  The creation date of the document. If not appending to an existing PDF file, this will default to the current time.
  New in version 5.3.0.
  - modDate
  The modification date of the document. If not appending to an existing PDF file, this will default to the current time.
  New in version 5.3.0.
  XV Thumbnails¶
  Pillow can read XV thumbnail files.
  Identify-only formats¶
  BUFR¶
  New in version 1.1.3.
  Pillow provides a stub driver for BUFR files.
  To add read or write support to your application, use
  PIL.BufrStubImagePlugin.register_handler().
  FITS¶
  New in version 1.1.5.
  Pillow provides a stub driver for FITS files.
  To add read or write support to your application, use
  PIL.FitsStubImagePlugin.register_handler().
  GRIB¶
  New in version 1.1.5.
  Pillow Pillow.
  To add read or write support to your application, use
  PIL.GribStubImagePlugin.register_handler().
  HDF5¶
  New in version 1.1.5.
  Pillow provides a stub driver for HDF5 files.
  To add read or write support to your application, use
  PIL.Hdf5StubImagePlugin.register_handler().