| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
""" |
| 6 |
Module that contain info about the Pillow formats. The first part of |
| 7 |
this module generates this info and writes it to its own bottom half |
| 8 |
if run as a script. |
| 9 |
""" |
| 10 |
|
| 11 |
import warnings |
| 12 |
|
| 13 |
warnings.warn( |
| 14 |
"The `PillowFormat` plugin is deprecated and will be removed in ImageIO v3." |
| 15 |
" Use the new `PillowPlugin` instead.", |
| 16 |
DeprecationWarning, |
| 17 |
) |
| 18 |
|
| 19 |
|
| 20 |
def generate_info(): |
| 21 |
from urllib.request import urlopen |
| 22 |
import PIL |
| 23 |
from PIL import Image |
| 24 |
|
| 25 |
Image.init() |
| 26 |
|
| 27 |
ids = [] |
| 28 |
formats = [] |
| 29 |
docs = {} |
| 30 |
|
| 31 |
|
| 32 |
for mod_name in dir(PIL): |
| 33 |
if "ImagePlugin" in mod_name: |
| 34 |
mod = getattr(PIL, mod_name) |
| 35 |
for ob_name in dir(mod): |
| 36 |
ob = getattr(mod, ob_name) |
| 37 |
if isinstance(ob, type) and issubclass(ob, Image.Image): |
| 38 |
if ob.format in ids: |
| 39 |
print("Found duplicate for", ob.format) |
| 40 |
else: |
| 41 |
ids.append(ob.format) |
| 42 |
formats.append((ob.format, ob.format_description)) |
| 43 |
|
| 44 |
|
| 45 |
for i in range(len(formats)): |
| 46 |
id, summary = formats[i] |
| 47 |
ext = " ".join([e for e in Image.EXTENSION if Image.EXTENSION[e] == id]) |
| 48 |
formats[i] = id, summary, ext |
| 49 |
|
| 50 |
|
| 51 |
url = "https://raw.githubusercontent.com/python-pillow/Pillow/master/docs/handbook/image-file-formats.rst" |
| 52 |
lines = urlopen(url).read().decode().splitlines() |
| 53 |
lines.append("End") |
| 54 |
lines.append("---") |
| 55 |
|
| 56 |
|
| 57 |
cur_name = "" |
| 58 |
cur_part = [] |
| 59 |
for i in range(len(lines)): |
| 60 |
line = lines[i] |
| 61 |
if line.startswith(("^^^", "---", "===")): |
| 62 |
if cur_name and cur_name in ids: |
| 63 |
text = "\n".join(cur_part[:-1]) |
| 64 |
text = text.replace("versionadded::", "versionadded:: Pillow ") |
| 65 |
text = text.replace("Image.open`", "Image.write`") |
| 66 |
docs[cur_name] = text |
| 67 |
cur_part = [] |
| 68 |
cur_name = lines[i - 1].strip().replace(" ", "").upper() |
| 69 |
else: |
| 70 |
cur_part.append(" " + line) |
| 71 |
|
| 72 |
|
| 73 |
for id in ids: |
| 74 |
if id in docs: |
| 75 |
docs[id] = "*From the Pillow docs:*\n\n" + docs[id] |
| 76 |
else: |
| 77 |
docs[id] = "No docs for %s." % id |
| 78 |
print("no docs for", id) |
| 79 |
|
| 80 |
|
| 81 |
formats.sort(key=lambda x: x[0]) |
| 82 |
ids.sort() |
| 83 |
|
| 84 |
|
| 85 |
code = open(__file__, "rb").read().decode() |
| 86 |
code, divider, _ = code.partition("## BELOW IS " + "AUTOGENERATED") |
| 87 |
code += divider + "\n\n" |
| 88 |
|
| 89 |
|
| 90 |
code += "pillow_formats = [\n" |
| 91 |
for i in range(len(formats)): |
| 92 |
print(formats[i]) |
| 93 |
code += " (%r, %r, %r),\n" % formats[i] |
| 94 |
code += " ]\n\n\n" |
| 95 |
|
| 96 |
|
| 97 |
code += "pillow_docs = {\n" |
| 98 |
for id in ids: |
| 99 |
code += '%r:\nu"""%s""",\n' % (id, docs[id]) |
| 100 |
code += "}\n" |
| 101 |
|
| 102 |
|
| 103 |
with open(__file__, "wb") as f: |
| 104 |
f.write(code.encode()) |
| 105 |
|
| 106 |
|
| 107 |
if __name__ == "__main__": |
| 108 |
generate_info() |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
pillow_formats = [ |
| 114 |
("BMP", "Windows Bitmap", ".bmp"), |
| 115 |
("BUFR", "BUFR", ".bufr"), |
| 116 |
("CUR", "Windows Cursor", ".cur"), |
| 117 |
("DCX", "Intel DCX", ".dcx"), |
| 118 |
("DDS", "DirectDraw Surface", ".dds"), |
| 119 |
("DIB", "Windows Bitmap", ""), |
| 120 |
("EPS", "Encapsulated Postscript", ".ps .eps"), |
| 121 |
("FITS", "FITS", ".fit .fits"), |
| 122 |
("FLI", "Autodesk FLI/FLC Animation", ".fli .flc"), |
| 123 |
("FPX", "FlashPix", ".fpx"), |
| 124 |
("FTEX", "Texture File Format (IW2:EOC)", ".ftc .ftu"), |
| 125 |
("GBR", "GIMP brush file", ".gbr"), |
| 126 |
("GIF", "Compuserve GIF", ".gif"), |
| 127 |
("GRIB", "GRIB", ".grib"), |
| 128 |
("HDF5", "HDF5", ".h5 .hdf"), |
| 129 |
("ICNS", "Mac OS icns resource", ".icns"), |
| 130 |
("ICO", "Windows Icon", ".ico"), |
| 131 |
("IM", "IFUNC Image Memory", ".im"), |
| 132 |
("IMT", "IM Tools", ""), |
| 133 |
("IPTC", "IPTC/NAA", ".iim"), |
| 134 |
("JPEG", "JPEG (ISO 10918)", ".jfif .jpe .jpg .jpeg"), |
| 135 |
("JPEG2000", "JPEG 2000 (ISO 15444)", ".jp2 .j2k .jpc .jpf .jpx .j2c"), |
| 136 |
("MCIDAS", "McIdas area file", ""), |
| 137 |
("MIC", "Microsoft Image Composer", ".mic"), |
| 138 |
("MPEG", "MPEG", ".mpg .mpeg"), |
| 139 |
("MPO", "MPO (CIPA DC-007)", ".mpo"), |
| 140 |
("MSP", "Windows Paint", ".msp"), |
| 141 |
("PCD", "Kodak PhotoCD", ".pcd"), |
| 142 |
("PCX", "Paintbrush", ".pcx"), |
| 143 |
("PIXAR", "PIXAR raster image", ".pxr"), |
| 144 |
("PNG", "Portable network graphics", ".png"), |
| 145 |
("PPM", "Pbmplus image", ".pbm .pgm .ppm"), |
| 146 |
("PSD", "Adobe Photoshop", ".psd"), |
| 147 |
("SGI", "SGI Image File Format", ".bw .rgb .rgba .sgi"), |
| 148 |
("SPIDER", "Spider 2D image", ""), |
| 149 |
("SUN", "Sun Raster File", ".ras"), |
| 150 |
("TGA", "Targa", ".tga"), |
| 151 |
("TIFF", "Adobe TIFF", ".tif .tiff"), |
| 152 |
("WMF", "Windows Metafile", ".wmf .emf"), |
| 153 |
("XBM", "X11 Bitmap", ".xbm"), |
| 154 |
("XPM", "X11 Pixel Map", ".xpm"), |
| 155 |
("XVThumb", "XV thumbnail image", ""), |
| 156 |
] |
| 157 |
|
| 158 |
|
| 159 |
pillow_docs = { |
| 160 |
"BMP": """*From the Pillow docs:* |
| 161 |
|
| 162 |
|
| 163 |
PIL reads and writes Windows and OS/2 BMP files containing ``1``, ``L``, ``P``, |
| 164 |
or ``RGB`` data. 16-colour images are read as ``P`` images. Run-length encoding |
| 165 |
is not supported. |
| 166 |
|
| 167 |
The :py:meth:`~PIL.Image.Image.write` method sets the following |
| 168 |
:py:attr:`~PIL.Image.Image.info` properties: |
| 169 |
|
| 170 |
**compression** |
| 171 |
Set to ``bmp_rle`` if the file is run-length encoded. |
| 172 |
""", |
| 173 |
"BUFR": """*From the Pillow docs:* |
| 174 |
|
| 175 |
|
| 176 |
.. versionadded:: Pillow 1.1.3 |
| 177 |
|
| 178 |
PIL provides a stub driver for BUFR files. |
| 179 |
|
| 180 |
To add read or write support to your application, use |
| 181 |
:py:func:`PIL.BufrStubImagePlugin.register_handler`. |
| 182 |
""", |
| 183 |
"CUR": """*From the Pillow docs:* |
| 184 |
|
| 185 |
|
| 186 |
CUR is used to store cursors on Windows. The CUR decoder reads the largest |
| 187 |
available cursor. Animated cursors are not supported. |
| 188 |
""", |
| 189 |
"DCX": """*From the Pillow docs:* |
| 190 |
|
| 191 |
|
| 192 |
DCX is a container file format for PCX files, defined by Intel. The DCX format |
| 193 |
is commonly used in fax applications. The DCX decoder can read files containing |
| 194 |
``1``, ``L``, ``P``, or ``RGB`` data. |
| 195 |
|
| 196 |
When the file is opened, only the first image is read. You can use |
| 197 |
:py:meth:`~file.seek` or :py:mod:`~PIL.ImageSequence` to read other images. |
| 198 |
|
| 199 |
""", |
| 200 |
"DDS": """*From the Pillow docs:* |
| 201 |
|
| 202 |
|
| 203 |
DDS is a popular container texture format used in video games and natively |
| 204 |
supported by DirectX. |
| 205 |
Currently, DXT1, DXT3, and DXT5 pixel formats are supported and only in ``RGBA`` |
| 206 |
mode. |
| 207 |
|
| 208 |
.. versionadded:: Pillow 3.4.0 DXT3 |
| 209 |
""", |
| 210 |
"DIB": """No docs for DIB.""", |
| 211 |
"EPS": """*From the Pillow docs:* |
| 212 |
|
| 213 |
|
| 214 |
PIL identifies EPS files containing image data, and can read files that contain |
| 215 |
embedded raster images (ImageData descriptors). If Ghostscript is available, |
| 216 |
other EPS files can be read as well. The EPS driver can also write EPS |
| 217 |
images. The EPS driver can read EPS images in ``L``, ``LAB``, ``RGB`` and |
| 218 |
``CMYK`` mode, but Ghostscript may convert the images to ``RGB`` mode rather |
| 219 |
than leaving them in the original color space. The EPS driver can write images |
| 220 |
in ``L``, ``RGB`` and ``CMYK`` modes. |
| 221 |
|
| 222 |
If Ghostscript is available, you can call the :py:meth:`~PIL.Image.Image.load` |
| 223 |
method with the following parameter to affect how Ghostscript renders the EPS |
| 224 |
|
| 225 |
**scale** |
| 226 |
Affects the scale of the resultant rasterized image. If the EPS suggests |
| 227 |
that the image be rendered at 100px x 100px, setting this parameter to |
| 228 |
2 will make the Ghostscript render a 200px x 200px image instead. The |
| 229 |
relative position of the bounding box is maintained:: |
| 230 |
|
| 231 |
im = Image.open(...) |
| 232 |
im.size #(100,100) |
| 233 |
im.load(scale=2) |
| 234 |
im.size #(200,200) |
| 235 |
""", |
| 236 |
"FITS": """*From the Pillow docs:* |
| 237 |
|
| 238 |
|
| 239 |
.. versionadded:: Pillow 1.1.5 |
| 240 |
|
| 241 |
PIL provides a stub driver for FITS files. |
| 242 |
|
| 243 |
To add read or write support to your application, use |
| 244 |
:py:func:`PIL.FitsStubImagePlugin.register_handler`. |
| 245 |
""", |
| 246 |
"FLI": """No docs for FLI.""", |
| 247 |
"FPX": """*From the Pillow docs:* |
| 248 |
|
| 249 |
|
| 250 |
PIL reads Kodak FlashPix files. In the current version, only the highest |
| 251 |
resolution image is read from the file, and the viewing transform is not taken |
| 252 |
into account. |
| 253 |
|
| 254 |
.. note:: |
| 255 |
|
| 256 |
To enable full FlashPix support, you need to build and install the IJG JPEG |
| 257 |
library before building the Python Imaging Library. See the distribution |
| 258 |
README for details. |
| 259 |
""", |
| 260 |
"FTEX": """*From the Pillow docs:* |
| 261 |
|
| 262 |
|
| 263 |
.. versionadded:: Pillow 3.2.0 |
| 264 |
|
| 265 |
The FTEX decoder reads textures used for 3D objects in |
| 266 |
Independence War 2: Edge Of Chaos. The plugin reads a single texture |
| 267 |
per file, in the compressed and uncompressed formats. |
| 268 |
""", |
| 269 |
"GBR": """*From the Pillow docs:* |
| 270 |
|
| 271 |
|
| 272 |
The GBR decoder reads GIMP brush files, version 1 and 2. |
| 273 |
|
| 274 |
The :py:meth:`~PIL.Image.Image.write` method sets the following |
| 275 |
:py:attr:`~PIL.Image.Image.info` properties: |
| 276 |
|
| 277 |
**comment** |
| 278 |
The brush name. |
| 279 |
|
| 280 |
**spacing** |
| 281 |
The spacing between the brushes, in pixels. Version 2 only. |
| 282 |
|
| 283 |
GD |
| 284 |
^^ |
| 285 |
|
| 286 |
PIL reads uncompressed GD files. Note that this file format cannot be |
| 287 |
automatically identified, so you must use :py:func:`PIL.GdImageFile.open` to |
| 288 |
read such a file. |
| 289 |
|
| 290 |
The :py:meth:`~PIL.Image.Image.write` method sets the following |
| 291 |
:py:attr:`~PIL.Image.Image.info` properties: |
| 292 |
|
| 293 |
**transparency** |
| 294 |
Transparency color index. This key is omitted if the image is not |
| 295 |
transparent. |
| 296 |
""", |
| 297 |
"GIF": """*From the Pillow docs:* |
| 298 |
|
| 299 |
|
| 300 |
PIL reads GIF87a and GIF89a versions of the GIF file format. The library writes |
| 301 |
run-length encoded files in GIF87a by default, unless GIF89a features |
| 302 |
are used or GIF89a is already in use. |
| 303 |
|
| 304 |
Note that GIF files are always read as grayscale (``L``) |
| 305 |
or palette mode (``P``) images. |
| 306 |
|
| 307 |
The :py:meth:`~PIL.Image.Image.write` method sets the following |
| 308 |
:py:attr:`~PIL.Image.Image.info` properties: |
| 309 |
|
| 310 |
**background** |
| 311 |
Default background color (a palette color index). |
| 312 |
|
| 313 |
**transparency** |
| 314 |
Transparency color index. This key is omitted if the image is not |
| 315 |
transparent. |
| 316 |
|
| 317 |
**version** |
| 318 |
Version (either ``GIF87a`` or ``GIF89a``). |
| 319 |
|
| 320 |
**duration** |
| 321 |
May not be present. The time to display the current frame |
| 322 |
of the GIF, in milliseconds. |
| 323 |
|
| 324 |
**loop** |
| 325 |
May not be present. The number of times the GIF should loop. |
| 326 |
|
| 327 |
Reading sequences |
| 328 |
~~~~~~~~~~~~~~~~~ |
| 329 |
|
| 330 |
The GIF loader supports the :py:meth:`~file.seek` and :py:meth:`~file.tell` |
| 331 |
methods. You can seek to the next frame (``im.seek(im.tell() + 1)``), or rewind |
| 332 |
the file by seeking to the first frame. Random access is not supported. |
| 333 |
|
| 334 |
``im.seek()`` raises an ``EOFError`` if you try to seek after the last frame. |
| 335 |
|
| 336 |
Saving |
| 337 |
~~~~~~ |
| 338 |
|
| 339 |
When calling :py:meth:`~PIL.Image.Image.save`, the following options |
| 340 |
are available:: |
| 341 |
|
| 342 |
im.save(out, save_all=True, append_images=[im1, im2, ...]) |
| 343 |
|
| 344 |
**save_all** |
| 345 |
If present and true, all frames of the image will be saved. If |
| 346 |
not, then only the first frame of a multiframe image will be saved. |
| 347 |
|
| 348 |
**append_images** |
| 349 |
A list of images to append as additional frames. Each of the |
| 350 |
images in the list can be single or multiframe images. |
| 351 |
This is currently only supported for GIF, PDF, TIFF, and WebP. |
| 352 |
|
| 353 |
**duration** |
| 354 |
The display duration of each frame of the multiframe gif, in |
| 355 |
milliseconds. Pass a single integer for a constant duration, or a |
| 356 |
list or tuple to set the duration for each frame separately. |
| 357 |
|
| 358 |
**loop** |
| 359 |
Integer number of times the GIF should loop. |
| 360 |
|
| 361 |
**optimize** |
| 362 |
If present and true, attempt to compress the palette by |
| 363 |
eliminating unused colors. This is only useful if the palette can |
| 364 |
be compressed to the next smaller power of 2 elements. |
| 365 |
|
| 366 |
**palette** |
| 367 |
Use the specified palette for the saved image. The palette should |
| 368 |
be a bytes or bytearray object containing the palette entries in |
| 369 |
RGBRGB... form. It should be no more than 768 bytes. Alternately, |
| 370 |
the palette can be passed in as an |
| 371 |
:py:class:`PIL.ImagePalette.ImagePalette` object. |
| 372 |
|
| 373 |
**disposal** |
| 374 |
Indicates the way in which the graphic is to be treated after being displayed. |
| 375 |
|
| 376 |
* 0 - No disposal specified. |
| 377 |
* 1 - Do not dispose. |
| 378 |
* 2 - Restore to background color. |
| 379 |
* 3 - Restore to previous content. |
| 380 |
|
| 381 |
Pass a single integer for a constant disposal, or a list or tuple |
| 382 |
to set the disposal for each frame separately. |
| 383 |
|
| 384 |
Reading local images |
| 385 |
~~~~~~~~~~~~~~~~~~~~ |
| 386 |
|
| 387 |
The GIF loader creates an image memory the same size as the GIF file’s *logical |
| 388 |
screen size*, and pastes the actual pixel data (the *local image*) into this |
| 389 |
image. If you only want the actual pixel rectangle, you can manipulate the |
| 390 |
:py:attr:`~PIL.Image.Image.size` and :py:attr:`~PIL.Image.Image.tile` |
| 391 |
attributes before loading the file:: |
| 392 |
|
| 393 |
im = Image.open(...) |
| 394 |
|
| 395 |
if im.tile[0][0] == "gif": |
| 396 |
# only read the first "local image" from this GIF file |
| 397 |
tag, (x0, y0, x1, y1), offset, extra = im.tile[0] |
| 398 |
im.size = (x1 - x0, y1 - y0) |
| 399 |
im.tile = [(tag, (0, 0) + im.size, offset, extra)] |
| 400 |
""", |
| 401 |
"GRIB": """*From the Pillow docs:* |
| 402 |
|
| 403 |
|
| 404 |
.. versionadded:: Pillow 1.1.5 |
| 405 |
|
| 406 |
PIL provides a stub driver for GRIB files. |
| 407 |
|
| 408 |
The driver requires the file to start with a GRIB header. If you have files |
| 409 |
with embedded GRIB data, or files with multiple GRIB fields, your application |
| 410 |
has to seek to the header before passing the file handle to PIL. |
| 411 |
|
| 412 |
To add read or write support to your application, use |
| 413 |
:py:func:`PIL.GribStubImagePlugin.register_handler`. |
| 414 |
""", |
| 415 |
"HDF5": """*From the Pillow docs:* |
| 416 |
|
| 417 |
|
| 418 |
.. versionadded:: Pillow 1.1.5 |
| 419 |
|
| 420 |
PIL provides a stub driver for HDF5 files. |
| 421 |
|
| 422 |
To add read or write support to your application, use |
| 423 |
:py:func:`PIL.Hdf5StubImagePlugin.register_handler`. |
| 424 |
""", |
| 425 |
"ICNS": """*From the Pillow docs:* |
| 426 |
|
| 427 |
|
| 428 |
PIL reads and (macOS only) writes macOS ``.icns`` files. By default, the |
| 429 |
largest available icon is read, though you can override this by setting the |
| 430 |
:py:attr:`~PIL.Image.Image.size` property before calling |
| 431 |
:py:meth:`~PIL.Image.Image.load`. The :py:meth:`~PIL.Image.Image.write` method |
| 432 |
sets the following :py:attr:`~PIL.Image.Image.info` property: |
| 433 |
|
| 434 |
**sizes** |
| 435 |
A list of supported sizes found in this icon file; these are a |
| 436 |
3-tuple, ``(width, height, scale)``, where ``scale`` is 2 for a retina |
| 437 |
icon and 1 for a standard icon. You *are* permitted to use this 3-tuple |
| 438 |
format for the :py:attr:`~PIL.Image.Image.size` property if you set it |
| 439 |
before calling :py:meth:`~PIL.Image.Image.load`; after loading, the size |
| 440 |
will be reset to a 2-tuple containing pixel dimensions (so, e.g. if you |
| 441 |
ask for ``(512, 512, 2)``, the final value of |
| 442 |
:py:attr:`~PIL.Image.Image.size` will be ``(1024, 1024)``). |
| 443 |
""", |
| 444 |
"ICO": """*From the Pillow docs:* |
| 445 |
|
| 446 |
|
| 447 |
ICO is used to store icons on Windows. The largest available icon is read. |
| 448 |
|
| 449 |
The :py:meth:`~PIL.Image.Image.save` method supports the following options: |
| 450 |
|
| 451 |
**sizes** |
| 452 |
A list of sizes including in this ico file; these are a 2-tuple, |
| 453 |
``(width, height)``; Default to ``[(16, 16), (24, 24), (32, 32), (48, 48), |
| 454 |
(64, 64), (128, 128), (256, 256)]``. Any sizes bigger than the original |
| 455 |
size or 256 will be ignored. |
| 456 |
|
| 457 |
IM |
| 458 |
^^ |
| 459 |
|
| 460 |
IM is a format used by LabEye and other applications based on the IFUNC image |
| 461 |
processing library. The library reads and writes most uncompressed interchange |
| 462 |
versions of this format. |
| 463 |
|
| 464 |
IM is the only format that can store all internal PIL formats. |
| 465 |
""", |
| 466 |
"IM": """No docs for IM.""", |
| 467 |
"IMT": """*From the Pillow docs:* |
| 468 |
|
| 469 |
|
| 470 |
PIL reads Image Tools images containing ``L`` data. |
| 471 |
""", |
| 472 |
"IPTC": """No docs for IPTC.""", |
| 473 |
"JPEG": """*From the Pillow docs:* |
| 474 |
|
| 475 |
|
| 476 |
PIL reads JPEG, JFIF, and Adobe JPEG files containing ``L``, ``RGB``, or |
| 477 |
``CMYK`` data. It writes standard and progressive JFIF files. |
| 478 |
|
| 479 |
Using the :py:meth:`~PIL.Image.Image.draft` method, you can speed things up by |
| 480 |
converting ``RGB`` images to ``L``, and resize images to 1/2, 1/4 or 1/8 of |
| 481 |
their original size while loading them. |
| 482 |
|
| 483 |
The :py:meth:`~PIL.Image.Image.write` method may set the following |
| 484 |
:py:attr:`~PIL.Image.Image.info` properties if available: |
| 485 |
|
| 486 |
**jfif** |
| 487 |
JFIF application marker found. If the file is not a JFIF file, this key is |
| 488 |
not present. |
| 489 |
|
| 490 |
**jfif_version** |
| 491 |
A tuple representing the jfif version, (major version, minor version). |
| 492 |
|
| 493 |
**jfif_density** |
| 494 |
A tuple representing the pixel density of the image, in units specified |
| 495 |
by jfif_unit. |
| 496 |
|
| 497 |
**jfif_unit** |
| 498 |
Units for the jfif_density: |
| 499 |
|
| 500 |
* 0 - No Units |
| 501 |
* 1 - Pixels per Inch |
| 502 |
* 2 - Pixels per Centimeter |
| 503 |
|
| 504 |
**dpi** |
| 505 |
A tuple representing the reported pixel density in pixels per inch, if |
| 506 |
the file is a jfif file and the units are in inches. |
| 507 |
|
| 508 |
**adobe** |
| 509 |
Adobe application marker found. If the file is not an Adobe JPEG file, this |
| 510 |
key is not present. |
| 511 |
|
| 512 |
**adobe_transform** |
| 513 |
Vendor Specific Tag. |
| 514 |
|
| 515 |
**progression** |
| 516 |
Indicates that this is a progressive JPEG file. |
| 517 |
|
| 518 |
**icc_profile** |
| 519 |
The ICC color profile for the image. |
| 520 |
|
| 521 |
**exif** |
| 522 |
Raw EXIF data from the image. |
| 523 |
|
| 524 |
|
| 525 |
The :py:meth:`~PIL.Image.Image.save` method supports the following options: |
| 526 |
|
| 527 |
**quality** |
| 528 |
The image quality, on a scale from 1 (worst) to 95 (best). The default is |
| 529 |
75. Values above 95 should be avoided; 100 disables portions of the JPEG |
| 530 |
compression algorithm, and results in large files with hardly any gain in |
| 531 |
image quality. |
| 532 |
|
| 533 |
**optimize** |
| 534 |
If present and true, indicates that the encoder should make an extra pass |
| 535 |
over the image in order to select optimal encoder settings. |
| 536 |
|
| 537 |
**progressive** |
| 538 |
If present and true, indicates that this image should be stored as a |
| 539 |
progressive JPEG file. |
| 540 |
|
| 541 |
**dpi** |
| 542 |
A tuple of integers representing the pixel density, ``(x,y)``. |
| 543 |
|
| 544 |
**icc_profile** |
| 545 |
If present and true, the image is stored with the provided ICC profile. |
| 546 |
If this parameter is not provided, the image will be saved with no profile |
| 547 |
attached. To preserve the existing profile:: |
| 548 |
|
| 549 |
im.save(filename, 'jpeg', icc_profile=im.info.get('icc_profile')) |
| 550 |
|
| 551 |
**exif** |
| 552 |
If present, the image will be stored with the provided raw EXIF data. |
| 553 |
|
| 554 |
**subsampling** |
| 555 |
If present, sets the subsampling for the encoder. |
| 556 |
|
| 557 |
* ``keep``: Only valid for JPEG files, will retain the original image setting. |
| 558 |
* ``4:4:4``, ``4:2:2``, ``4:2:0``: Specific sampling values |
| 559 |
* ``-1``: equivalent to ``keep`` |
| 560 |
* ``0``: equivalent to ``4:4:4`` |
| 561 |
* ``1``: equivalent to ``4:2:2`` |
| 562 |
* ``2``: equivalent to ``4:2:0`` |
| 563 |
|
| 564 |
**qtables** |
| 565 |
If present, sets the qtables for the encoder. This is listed as an |
| 566 |
advanced option for wizards in the JPEG documentation. Use with |
| 567 |
caution. ``qtables`` can be one of several types of values: |
| 568 |
|
| 569 |
* a string, naming a preset, e.g. ``keep``, ``web_low``, or ``web_high`` |
| 570 |
* a list, tuple, or dictionary (with integer keys = |
| 571 |
range(len(keys))) of lists of 64 integers. There must be |
| 572 |
between 2 and 4 tables. |
| 573 |
|
| 574 |
.. versionadded:: Pillow 2.5.0 |
| 575 |
|
| 576 |
|
| 577 |
.. note:: |
| 578 |
|
| 579 |
To enable JPEG support, you need to build and install the IJG JPEG library |
| 580 |
before building the Python Imaging Library. See the distribution README for |
| 581 |
details. |
| 582 |
""", |
| 583 |
"JPEG2000": """*From the Pillow docs:* |
| 584 |
|
| 585 |
|
| 586 |
.. versionadded:: Pillow 2.4.0 |
| 587 |
|
| 588 |
PIL reads and writes JPEG 2000 files containing ``L``, ``LA``, ``RGB`` or |
| 589 |
``RGBA`` data. It can also read files containing ``YCbCr`` data, which it |
| 590 |
converts on read into ``RGB`` or ``RGBA`` depending on whether or not there is |
| 591 |
an alpha channel. PIL supports JPEG 2000 raw codestreams (``.j2k`` files), as |
| 592 |
well as boxed JPEG 2000 files (``.j2p`` or ``.jpx`` files). PIL does *not* |
| 593 |
support files whose components have different sampling frequencies. |
| 594 |
|
| 595 |
When loading, if you set the ``mode`` on the image prior to the |
| 596 |
:py:meth:`~PIL.Image.Image.load` method being invoked, you can ask PIL to |
| 597 |
convert the image to either ``RGB`` or ``RGBA`` rather than choosing for |
| 598 |
itself. It is also possible to set ``reduce`` to the number of resolutions to |
| 599 |
discard (each one reduces the size of the resulting image by a factor of 2), |
| 600 |
and ``layers`` to specify the number of quality layers to load. |
| 601 |
|
| 602 |
The :py:meth:`~PIL.Image.Image.save` method supports the following options: |
| 603 |
|
| 604 |
**offset** |
| 605 |
The image offset, as a tuple of integers, e.g. (16, 16) |
| 606 |
|
| 607 |
**tile_offset** |
| 608 |
The tile offset, again as a 2-tuple of integers. |
| 609 |
|
| 610 |
**tile_size** |
| 611 |
The tile size as a 2-tuple. If not specified, or if set to None, the |
| 612 |
image will be saved without tiling. |
| 613 |
|
| 614 |
**quality_mode** |
| 615 |
Either `"rates"` or `"dB"` depending on the units you want to use to |
| 616 |
specify image quality. |
| 617 |
|
| 618 |
**quality_layers** |
| 619 |
A sequence of numbers, each of which represents either an approximate size |
| 620 |
reduction (if quality mode is `"rates"`) or a signal to noise ratio value |
| 621 |
in decibels. If not specified, defaults to a single layer of full quality. |
| 622 |
|
| 623 |
**num_resolutions** |
| 624 |
The number of different image resolutions to be stored (which corresponds |
| 625 |
to the number of Discrete Wavelet Transform decompositions plus one). |
| 626 |
|
| 627 |
**codeblock_size** |
| 628 |
The code-block size as a 2-tuple. Minimum size is 4 x 4, maximum is 1024 x |
| 629 |
1024, with the additional restriction that no code-block may have more |
| 630 |
than 4096 coefficients (i.e. the product of the two numbers must be no |
| 631 |
greater than 4096). |
| 632 |
|
| 633 |
**precinct_size** |
| 634 |
The precinct size as a 2-tuple. Must be a power of two along both axes, |
| 635 |
and must be greater than the code-block size. |
| 636 |
|
| 637 |
**irreversible** |
| 638 |
If ``True``, use the lossy Irreversible Color Transformation |
| 639 |
followed by DWT 9-7. Defaults to ``False``, which means to use the |
| 640 |
Reversible Color Transformation with DWT 5-3. |
| 641 |
|
| 642 |
**progression** |
| 643 |
Controls the progression order; must be one of ``"LRCP"``, ``"RLCP"``, |
| 644 |
``"RPCL"``, ``"PCRL"``, ``"CPRL"``. The letters stand for Component, |
| 645 |
Position, Resolution and Layer respectively and control the order of |
| 646 |
encoding, the idea being that e.g. an image encoded using LRCP mode can |
| 647 |
have its quality layers decoded as they arrive at the decoder, while one |
| 648 |
encoded using RLCP mode will have increasing resolutions decoded as they |
| 649 |
arrive, and so on. |
| 650 |
|
| 651 |
**cinema_mode** |
| 652 |
Set the encoder to produce output compliant with the digital cinema |
| 653 |
specifications. The options here are ``"no"`` (the default), |
| 654 |
``"cinema2k-24"`` for 24fps 2K, ``"cinema2k-48"`` for 48fps 2K, and |
| 655 |
``"cinema4k-24"`` for 24fps 4K. Note that for compliant 2K files, |
| 656 |
*at least one* of your image dimensions must match 2048 x 1080, while |
| 657 |
for compliant 4K files, *at least one* of the dimensions must match |
| 658 |
4096 x 2160. |
| 659 |
|
| 660 |
.. note:: |
| 661 |
|
| 662 |
To enable JPEG 2000 support, you need to build and install the OpenJPEG |
| 663 |
library, version 2.0.0 or higher, before building the Python Imaging |
| 664 |
Library. |
| 665 |
|
| 666 |
Windows users can install the OpenJPEG binaries available on the |
| 667 |
OpenJPEG website, but must add them to their PATH in order to use PIL (if |
| 668 |
you fail to do this, you will get errors about not being able to load the |
| 669 |
``_imaging`` DLL). |
| 670 |
""", |
| 671 |
"MCIDAS": """*From the Pillow docs:* |
| 672 |
|
| 673 |
|
| 674 |
PIL identifies and reads 8-bit McIdas area files. |
| 675 |
""", |
| 676 |
"MIC": """*From the Pillow docs:* |
| 677 |
|
| 678 |
|
| 679 |
PIL identifies and reads Microsoft Image Composer (MIC) files. When opened, the |
| 680 |
first sprite in the file is loaded. You can use :py:meth:`~file.seek` and |
| 681 |
:py:meth:`~file.tell` to read other sprites from the file. |
| 682 |
|
| 683 |
Note that there may be an embedded gamma of 2.2 in MIC files. |
| 684 |
""", |
| 685 |
"MPEG": """*From the Pillow docs:* |
| 686 |
|
| 687 |
|
| 688 |
PIL identifies MPEG files. |
| 689 |
""", |
| 690 |
"MPO": """*From the Pillow docs:* |
| 691 |
|
| 692 |
|
| 693 |
Pillow identifies and reads Multi Picture Object (MPO) files, loading the primary |
| 694 |
image when first opened. The :py:meth:`~file.seek` and :py:meth:`~file.tell` |
| 695 |
methods may be used to read other pictures from the file. The pictures are |
| 696 |
zero-indexed and random access is supported. |
| 697 |
""", |
| 698 |
"MSP": """*From the Pillow docs:* |
| 699 |
|
| 700 |
|
| 701 |
PIL identifies and reads MSP files from Windows 1 and 2. The library writes |
| 702 |
uncompressed (Windows 1) versions of this format. |
| 703 |
""", |
| 704 |
"PCD": """*From the Pillow docs:* |
| 705 |
|
| 706 |
|
| 707 |
PIL reads PhotoCD files containing ``RGB`` data. This only reads the 768x512 |
| 708 |
resolution image from the file. Higher resolutions are encoded in a proprietary |
| 709 |
encoding. |
| 710 |
""", |
| 711 |
"PCX": """*From the Pillow docs:* |
| 712 |
|
| 713 |
|
| 714 |
PIL reads and writes PCX files containing ``1``, ``L``, ``P``, or ``RGB`` data. |
| 715 |
""", |
| 716 |
"PIXAR": """*From the Pillow docs:* |
| 717 |
|
| 718 |
|
| 719 |
PIL provides limited support for PIXAR raster files. The library can identify |
| 720 |
and read “dumped” RGB files. |
| 721 |
|
| 722 |
The format code is ``PIXAR``. |
| 723 |
""", |
| 724 |
"PNG": """*From the Pillow docs:* |
| 725 |
|
| 726 |
|
| 727 |
PIL identifies, reads, and writes PNG files containing ``1``, ``L``, ``P``, |
| 728 |
``RGB``, or ``RGBA`` data. Interlaced files are supported as of v1.1.7. |
| 729 |
|
| 730 |
The :py:meth:`~PIL.Image.Image.write` method sets the following |
| 731 |
:py:attr:`~PIL.Image.Image.info` properties, when appropriate: |
| 732 |
|
| 733 |
**chromaticity** |
| 734 |
The chromaticity points, as an 8 tuple of floats. (``White Point |
| 735 |
X``, ``White Point Y``, ``Red X``, ``Red Y``, ``Green X``, ``Green |
| 736 |
Y``, ``Blue X``, ``Blue Y``) |
| 737 |
|
| 738 |
**gamma** |
| 739 |
Gamma, given as a floating point number. |
| 740 |
|
| 741 |
**srgb** |
| 742 |
The sRGB rendering intent as an integer. |
| 743 |
|
| 744 |
* 0 Perceptual |
| 745 |
* 1 Relative Colorimetric |
| 746 |
* 2 Saturation |
| 747 |
* 3 Absolute Colorimetric |
| 748 |
|
| 749 |
**transparency** |
| 750 |
For ``P`` images: Either the palette index for full transparent pixels, |
| 751 |
or a byte string with alpha values for each palette entry. |
| 752 |
|
| 753 |
For ``L`` and ``RGB`` images, the color that represents full transparent |
| 754 |
pixels in this image. |
| 755 |
|
| 756 |
This key is omitted if the image is not a transparent palette image. |
| 757 |
|
| 758 |
``Open`` also sets ``Image.text`` to a list of the values of the |
| 759 |
``tEXt``, ``zTXt``, and ``iTXt`` chunks of the PNG image. Individual |
| 760 |
compressed chunks are limited to a decompressed size of |
| 761 |
``PngImagePlugin.MAX_TEXT_CHUNK``, by default 1MB, to prevent |
| 762 |
decompression bombs. Additionally, the total size of all of the text |
| 763 |
chunks is limited to ``PngImagePlugin.MAX_TEXT_MEMORY``, defaulting to |
| 764 |
64MB. |
| 765 |
|
| 766 |
The :py:meth:`~PIL.Image.Image.save` method supports the following options: |
| 767 |
|
| 768 |
**optimize** |
| 769 |
If present and true, instructs the PNG writer to make the output file as |
| 770 |
small as possible. This includes extra processing in order to find optimal |
| 771 |
encoder settings. |
| 772 |
|
| 773 |
**transparency** |
| 774 |
For ``P``, ``L``, and ``RGB`` images, this option controls what |
| 775 |
color image to mark as transparent. |
| 776 |
|
| 777 |
For ``P`` images, this can be a either the palette index, |
| 778 |
or a byte string with alpha values for each palette entry. |
| 779 |
|
| 780 |
**dpi** |
| 781 |
A tuple of two numbers corresponding to the desired dpi in each direction. |
| 782 |
|
| 783 |
**pnginfo** |
| 784 |
A :py:class:`PIL.PngImagePlugin.PngInfo` instance containing text tags. |
| 785 |
|
| 786 |
**compress_level** |
| 787 |
ZLIB compression level, a number between 0 and 9: 1 gives best speed, |
| 788 |
9 gives best compression, 0 gives no compression at all. Default is 6. |
| 789 |
When ``optimize`` option is True ``compress_level`` has no effect |
| 790 |
(it is set to 9 regardless of a value passed). |
| 791 |
|
| 792 |
**icc_profile** |
| 793 |
The ICC Profile to include in the saved file. |
| 794 |
|
| 795 |
**bits (experimental)** |
| 796 |
For ``P`` images, this option controls how many bits to store. If omitted, |
| 797 |
the PNG writer uses 8 bits (256 colors). |
| 798 |
|
| 799 |
**dictionary (experimental)** |
| 800 |
Set the ZLIB encoder dictionary. |
| 801 |
|
| 802 |
.. note:: |
| 803 |
|
| 804 |
To enable PNG support, you need to build and install the ZLIB compression |
| 805 |
library before building the Python Imaging Library. See the installation |
| 806 |
documentation for details. |
| 807 |
""", |
| 808 |
"PPM": """*From the Pillow docs:* |
| 809 |
|
| 810 |
|
| 811 |
PIL reads and writes PBM, PGM and PPM files containing ``1``, ``L`` or ``RGB`` |
| 812 |
data. |
| 813 |
""", |
| 814 |
"PSD": """*From the Pillow docs:* |
| 815 |
|
| 816 |
|
| 817 |
PIL identifies and reads PSD files written by Adobe Photoshop 2.5 and 3.0. |
| 818 |
|
| 819 |
""", |
| 820 |
"SGI": """*From the Pillow docs:* |
| 821 |
|
| 822 |
|
| 823 |
Pillow reads and writes uncompressed ``L``, ``RGB``, and ``RGBA`` files. |
| 824 |
|
| 825 |
""", |
| 826 |
"SPIDER": """*From the Pillow docs:* |
| 827 |
|
| 828 |
|
| 829 |
PIL reads and writes SPIDER image files of 32-bit floating point data |
| 830 |
("F;32F"). |
| 831 |
|
| 832 |
PIL also reads SPIDER stack files containing sequences of SPIDER images. The |
| 833 |
:py:meth:`~file.seek` and :py:meth:`~file.tell` methods are supported, and |
| 834 |
random access is allowed. |
| 835 |
|
| 836 |
The :py:meth:`~PIL.Image.Image.write` method sets the following attributes: |
| 837 |
|
| 838 |
**format** |
| 839 |
Set to ``SPIDER`` |
| 840 |
|
| 841 |
**istack** |
| 842 |
Set to 1 if the file is an image stack, else 0. |
| 843 |
|
| 844 |
**nimages** |
| 845 |
Set to the number of images in the stack. |
| 846 |
|
| 847 |
A convenience method, :py:meth:`~PIL.Image.Image.convert2byte`, is provided for |
| 848 |
converting floating point data to byte data (mode ``L``):: |
| 849 |
|
| 850 |
im = Image.open('image001.spi').convert2byte() |
| 851 |
|
| 852 |
Writing files in SPIDER format |
| 853 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 854 |
|
| 855 |
The extension of SPIDER files may be any 3 alphanumeric characters. Therefore |
| 856 |
the output format must be specified explicitly:: |
| 857 |
|
| 858 |
im.save('newimage.spi', format='SPIDER') |
| 859 |
|
| 860 |
For more information about the SPIDER image processing package, see the |
| 861 |
`SPIDER homepage`_ at `Wadsworth Center`_. |
| 862 |
|
| 863 |
.. _SPIDER homepage: https://spider.wadsworth.org/spider_doc/spider/docs/spider.html |
| 864 |
.. _Wadsworth Center: https://www.wadsworth.org/ |
| 865 |
""", |
| 866 |
"SUN": """No docs for SUN.""", |
| 867 |
"TGA": """*From the Pillow docs:* |
| 868 |
|
| 869 |
|
| 870 |
PIL reads 24- and 32-bit uncompressed and run-length encoded TGA files. |
| 871 |
""", |
| 872 |
"TIFF": """*From the Pillow docs:* |
| 873 |
|
| 874 |
|
| 875 |
Pillow reads and writes TIFF files. It can read both striped and tiled |
| 876 |
images, pixel and plane interleaved multi-band images. If you have |
| 877 |
libtiff and its headers installed, PIL can read and write many kinds |
| 878 |
of compressed TIFF files. If not, PIL will only read and write |
| 879 |
uncompressed files. |
| 880 |
|
| 881 |
.. note:: |
| 882 |
|
| 883 |
Beginning in version 5.0.0, Pillow requires libtiff to read or |
| 884 |
write compressed files. Prior to that release, Pillow had buggy |
| 885 |
support for reading Packbits, LZW and JPEG compressed TIFFs |
| 886 |
without using libtiff. |
| 887 |
|
| 888 |
The :py:meth:`~PIL.Image.Image.write` method sets the following |
| 889 |
:py:attr:`~PIL.Image.Image.info` properties: |
| 890 |
|
| 891 |
**compression** |
| 892 |
Compression mode. |
| 893 |
|
| 894 |
.. versionadded:: Pillow 2.0.0 |
| 895 |
|
| 896 |
**dpi** |
| 897 |
Image resolution as an ``(xdpi, ydpi)`` tuple, where applicable. You can use |
| 898 |
the :py:attr:`~PIL.Image.Image.tag` attribute to get more detailed |
| 899 |
information about the image resolution. |
| 900 |
|
| 901 |
.. versionadded:: Pillow 1.1.5 |
| 902 |
|
| 903 |
**resolution** |
| 904 |
Image resolution as an ``(xres, yres)`` tuple, where applicable. This is a |
| 905 |
measurement in whichever unit is specified by the file. |
| 906 |
|
| 907 |
.. versionadded:: Pillow 1.1.5 |
| 908 |
|
| 909 |
|
| 910 |
The :py:attr:`~PIL.Image.Image.tag_v2` attribute contains a dictionary |
| 911 |
of TIFF metadata. The keys are numerical indexes from |
| 912 |
:py:attr:`~PIL.TiffTags.TAGS_V2`. Values are strings or numbers for single |
| 913 |
items, multiple values are returned in a tuple of values. Rational |
| 914 |
numbers are returned as a :py:class:`~PIL.TiffImagePlugin.IFDRational` |
| 915 |
object. |
| 916 |
|
| 917 |
.. versionadded:: Pillow 3.0.0 |
| 918 |
|
| 919 |
For compatibility with legacy code, the |
| 920 |
:py:attr:`~PIL.Image.Image.tag` attribute contains a dictionary of |
| 921 |
decoded TIFF fields as returned prior to version 3.0.0. Values are |
| 922 |
returned as either strings or tuples of numeric values. Rational |
| 923 |
numbers are returned as a tuple of ``(numerator, denominator)``. |
| 924 |
|
| 925 |
.. deprecated:: 3.0.0 |
| 926 |
|
| 927 |
|
| 928 |
Saving Tiff Images |
| 929 |
~~~~~~~~~~~~~~~~~~ |
| 930 |
|
| 931 |
The :py:meth:`~PIL.Image.Image.save` method can take the following keyword arguments: |
| 932 |
|
| 933 |
**save_all** |
| 934 |
If true, Pillow will save all frames of the image to a multiframe tiff document. |
| 935 |
|
| 936 |
.. versionadded:: Pillow 3.4.0 |
| 937 |
|
| 938 |
**tiffinfo** |
| 939 |
A :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` object or dict |
| 940 |
object containing tiff tags and values. The TIFF field type is |
| 941 |
autodetected for Numeric and string values, any other types |
| 942 |
require using an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` |
| 943 |
object and setting the type in |
| 944 |
:py:attr:`~PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype` with |
| 945 |
the appropriate numerical value from |
| 946 |
``TiffTags.TYPES``. |
| 947 |
|
| 948 |
.. versionadded:: Pillow 2.3.0 |
| 949 |
|
| 950 |
Metadata values that are of the rational type should be passed in |
| 951 |
using a :py:class:`~PIL.TiffImagePlugin.IFDRational` object. |
| 952 |
|
| 953 |
.. versionadded:: Pillow 3.1.0 |
| 954 |
|
| 955 |
For compatibility with legacy code, a |
| 956 |
:py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` object may |
| 957 |
be passed in this field. However, this is deprecated. |
| 958 |
|
| 959 |
.. versionadded:: Pillow 3.0.0 |
| 960 |
|
| 961 |
.. note:: |
| 962 |
|
| 963 |
Only some tags are currently supported when writing using |
| 964 |
libtiff. The supported list is found in |
| 965 |
:py:attr:`~PIL:TiffTags.LIBTIFF_CORE`. |
| 966 |
|
| 967 |
**compression** |
| 968 |
A string containing the desired compression method for the |
| 969 |
file. (valid only with libtiff installed) Valid compression |
| 970 |
methods are: ``None``, ``"tiff_ccitt"``, ``"group3"``, |
| 971 |
``"group4"``, ``"tiff_jpeg"``, ``"tiff_adobe_deflate"``, |
| 972 |
``"tiff_thunderscan"``, ``"tiff_deflate"``, ``"tiff_sgilog"``, |
| 973 |
``"tiff_sgilog24"``, ``"tiff_raw_16"`` |
| 974 |
|
| 975 |
These arguments to set the tiff header fields are an alternative to |
| 976 |
using the general tags available through tiffinfo. |
| 977 |
|
| 978 |
**description** |
| 979 |
|
| 980 |
**software** |
| 981 |
|
| 982 |
**date_time** |
| 983 |
|
| 984 |
**artist** |
| 985 |
|
| 986 |
**copyright** |
| 987 |
Strings |
| 988 |
|
| 989 |
**resolution_unit** |
| 990 |
A string of "inch", "centimeter" or "cm" |
| 991 |
|
| 992 |
**resolution** |
| 993 |
|
| 994 |
**x_resolution** |
| 995 |
|
| 996 |
**y_resolution** |
| 997 |
|
| 998 |
**dpi** |
| 999 |
Either a Float, 2 tuple of (numerator, denominator) or a |
| 1000 |
:py:class:`~PIL.TiffImagePlugin.IFDRational`. Resolution implies |
| 1001 |
an equal x and y resolution, dpi also implies a unit of inches. |
| 1002 |
|
| 1003 |
""", |
| 1004 |
"WMF": """*From the Pillow docs:* |
| 1005 |
|
| 1006 |
|
| 1007 |
PIL can identify playable WMF files. |
| 1008 |
|
| 1009 |
In PIL 1.1.4 and earlier, the WMF driver provides some limited rendering |
| 1010 |
support, but not enough to be useful for any real application. |
| 1011 |
|
| 1012 |
In PIL 1.1.5 and later, the WMF driver is a stub driver. To add WMF read or |
| 1013 |
write support to your application, use |
| 1014 |
:py:func:`PIL.WmfImagePlugin.register_handler` to register a WMF handler. |
| 1015 |
|
| 1016 |
:: |
| 1017 |
|
| 1018 |
from PIL import Image |
| 1019 |
from PIL import WmfImagePlugin |
| 1020 |
|
| 1021 |
class WmfHandler: |
| 1022 |
def open(self, im): |
| 1023 |
... |
| 1024 |
def load(self, im): |
| 1025 |
... |
| 1026 |
return image |
| 1027 |
def save(self, im, fp, filename): |
| 1028 |
... |
| 1029 |
|
| 1030 |
wmf_handler = WmfHandler() |
| 1031 |
|
| 1032 |
WmfImagePlugin.register_handler(wmf_handler) |
| 1033 |
|
| 1034 |
im = Image.open("sample.wmf")""", |
| 1035 |
"XBM": """*From the Pillow docs:* |
| 1036 |
|
| 1037 |
|
| 1038 |
PIL reads and writes X bitmap files (mode ``1``). |
| 1039 |
""", |
| 1040 |
"XPM": """*From the Pillow docs:* |
| 1041 |
|
| 1042 |
|
| 1043 |
PIL reads X pixmap files (mode ``P``) with 256 colors or less. |
| 1044 |
|
| 1045 |
The :py:meth:`~PIL.Image.Image.write` method sets the following |
| 1046 |
:py:attr:`~PIL.Image.Image.info` properties: |
| 1047 |
|
| 1048 |
**transparency** |
| 1049 |
Transparency color index. This key is omitted if the image is not |
| 1050 |
transparent. |
| 1051 |
""", |
| 1052 |
"XVThumb": """No docs for XVThumb.""", |
| 1053 |
} |