Skip to content

Commit d0ff4b5

Browse files
authored
Merge pull request #6632 from radarhere/options
2 parents bdbf59d + 15b2b7a commit d0ff4b5

File tree

1 file changed

+104
-5
lines changed

1 file changed

+104
-5
lines changed

docs/handbook/image-file-formats.rst

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ BLP is the Blizzard Mipmap Format, a texture format used in World of
3131
Warcraft. Pillow supports reading ``JPEG`` Compressed or raw ``BLP1``
3232
images, and all types of ``BLP2`` images.
3333

34+
Saving
35+
~~~~~~
36+
3437
Pillow supports writing BLP images. The :py:meth:`~PIL.Image.Image.save` method
3538
can take the following keyword arguments:
3639

@@ -46,6 +49,9 @@ or ``RGB`` data. 16-colour images are read as ``P`` images. 4-bit run-length enc
4649
is not supported. Support for reading 8-bit run-length encoding was added in Pillow
4750
9.1.0.
4851

52+
Opening
53+
~~~~~~~
54+
4955
The :py:meth:`~PIL.Image.open` method sets the following
5056
:py:attr:`~PIL.Image.Image.info` properties:
5157

@@ -78,6 +84,9 @@ EPS images. The EPS driver can read EPS images in ``L``, ``LAB``, ``RGB`` and
7884
than leaving them in the original color space. The EPS driver can write images
7985
in ``L``, ``RGB`` and ``CMYK`` modes.
8086

87+
Loading
88+
~~~~~~~
89+
8190
If Ghostscript is available, you can call the :py:meth:`~PIL.Image.Image.load`
8291
method with the following parameters to affect how Ghostscript renders the EPS
8392

@@ -134,6 +143,11 @@ To restore the default behavior, where ``P`` mode images are only converted to
134143
from PIL import GifImagePlugin
135144
GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_AFTER_FIRST
136145

146+
.. _gif-opening:
147+
148+
Opening
149+
~~~~~~~
150+
137151
The :py:meth:`~PIL.Image.open` method sets the following
138152
:py:attr:`~PIL.Image.Image.info` properties:
139153

@@ -171,6 +185,8 @@ to seek to the next frame (``im.seek(im.tell() + 1)``).
171185

172186
``im.seek()`` raises an :py:exc:`EOFError` if you try to seek after the last frame.
173187

188+
.. _gif-saving:
189+
174190
Saving
175191
~~~~~~
176192

@@ -278,6 +294,11 @@ sets the following :py:attr:`~PIL.Image.Image.info` property:
278294
ask for ``(512, 512, 2)``, the final value of
279295
:py:attr:`~PIL.Image.Image.size` will be ``(1024, 1024)``).
280296

297+
.. _icns-saving:
298+
299+
Saving
300+
~~~~~~
301+
281302
The :py:meth:`~PIL.Image.Image.save` method can take the following keyword arguments:
282303

283304
**append_images**
@@ -292,6 +313,11 @@ ICO
292313

293314
ICO is used to store icons on Windows. The largest available icon is read.
294315

316+
.. _ico-saving:
317+
318+
Saving
319+
~~~~~~
320+
295321
The :py:meth:`~PIL.Image.Image.save` method supports the following options:
296322

297323
**sizes**
@@ -337,6 +363,11 @@ their original size while loading them.
337363
By default Pillow doesn't allow loading of truncated JPEG files, set
338364
:data:`.ImageFile.LOAD_TRUNCATED_IMAGES` to override this.
339365

366+
.. _jpeg-opening:
367+
368+
Opening
369+
~~~~~~~
370+
340371
The :py:meth:`~PIL.Image.open` method may set the following
341372
:py:attr:`~PIL.Image.Image.info` properties if available:
342373

@@ -383,6 +414,10 @@ The :py:meth:`~PIL.Image.open` method may set the following
383414

384415
.. versionadded:: 7.1.0
385416

417+
.. _jpeg-saving:
418+
419+
Saving
420+
~~~~~~
386421

387422
The :py:meth:`~PIL.Image.Image.save` method supports the following options:
388423

@@ -464,6 +499,11 @@ itself. It is also possible to set ``reduce`` to the number of resolutions to
464499
discard (each one reduces the size of the resulting image by a factor of 2),
465500
and ``layers`` to specify the number of quality layers to load.
466501

502+
.. _jpeg-2000-saving:
503+
504+
Saving
505+
~~~~~~
506+
467507
The :py:meth:`~PIL.Image.Image.save` method supports the following options:
468508

469509
**offset**
@@ -575,6 +615,11 @@ called.
575615
By default Pillow doesn't allow loading of truncated PNG files, set
576616
:data:`.ImageFile.LOAD_TRUNCATED_IMAGES` to override this.
577617

618+
.. _png-opening:
619+
620+
Opening
621+
~~~~~~~
622+
578623
The :py:func:`~PIL.Image.open` function sets the following
579624
:py:attr:`~PIL.Image.Image.info` properties, when appropriate:
580625

@@ -613,6 +658,11 @@ decompression bombs. Additionally, the total size of all of the text
613658
chunks is limited to :data:`.PngImagePlugin.MAX_TEXT_MEMORY`, defaulting to
614659
64MB.
615660

661+
.. _png-saving:
662+
663+
Saving
664+
~~~~~~
665+
616666
The :py:meth:`~PIL.Image.Image.save` method supports the following options:
617667

618668
**optimize**
@@ -803,6 +853,11 @@ Pillow also reads SPIDER stack files containing sequences of SPIDER images. The
803853
:py:meth:`~PIL.Image.Image.seek` and :py:meth:`~PIL.Image.Image.tell` methods are supported, and
804854
random access is allowed.
805855

856+
.. _spider-opening:
857+
858+
Opening
859+
~~~~~~~
860+
806861
The :py:meth:`~PIL.Image.open` method sets the following attributes:
807862

808863
**format**
@@ -819,8 +874,10 @@ is provided for converting floating point data to byte data (mode ``L``)::
819874

820875
im = Image.open("image001.spi").convert2byte()
821876

822-
Writing files in SPIDER format
823-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
877+
.. _spider-saving:
878+
879+
Saving
880+
~~~~~~
824881

825882
The extension of SPIDER files may be any 3 alphanumeric characters. Therefore
826883
the output format must be specified explicitly::
@@ -837,6 +894,11 @@ Pillow reads and writes TGA images containing ``L``, ``LA``, ``P``,
837894
``RGB``, and ``RGBA`` data. Pillow can read and write both uncompressed and
838895
run-length encoded TGAs.
839896

897+
.. _tga-saving:
898+
899+
Saving
900+
~~~~~~
901+
840902
The :py:meth:`~PIL.Image.Image.save` method can take the following keyword arguments:
841903

842904
**compression**
@@ -871,6 +933,11 @@ uncompressed files.
871933
support for reading Packbits, LZW and JPEG compressed TIFFs
872934
without using libtiff.
873935

936+
.. _tiff-opening:
937+
938+
Opening
939+
~~~~~~~
940+
874941
The :py:meth:`~PIL.Image.open` method sets the following
875942
:py:attr:`~PIL.Image.Image.info` properties:
876943

@@ -922,8 +989,10 @@ and can be accessed in any order.
922989
``im.seek()`` raises an :py:exc:`EOFError` if you try to seek after the
923990
last frame.
924991

925-
Saving Tiff Images
926-
~~~~~~~~~~~~~~~~~~
992+
.. _tiff-saving:
993+
994+
Saving
995+
~~~~~~
927996

928997
The :py:meth:`~PIL.Image.Image.save` method can take the following keyword arguments:
929998

@@ -1035,6 +1104,11 @@ WebP
10351104
Pillow reads and writes WebP files. The specifics of Pillow's capabilities with
10361105
this format are currently undocumented.
10371106

1107+
.. _webp-saving:
1108+
1109+
Saving
1110+
~~~~~~
1111+
10381112
The :py:meth:`~PIL.Image.Image.save` method supports the following options:
10391113

10401114
**lossless**
@@ -1058,7 +1132,7 @@ The :py:meth:`~PIL.Image.Image.save` method supports the following options:
10581132
the system WebP library was built with webpmux support.
10591133

10601134
Saving sequences
1061-
~~~~~~~~~~~~~~~~~
1135+
~~~~~~~~~~~~~~~~
10621136

10631137
.. note::
10641138

@@ -1173,6 +1247,11 @@ GBR
11731247

11741248
The GBR decoder reads GIMP brush files, version 1 and 2.
11751249

1250+
.. _gbr-opening:
1251+
1252+
Opening
1253+
~~~~~~~
1254+
11761255
The :py:meth:`~PIL.Image.open` method sets the following
11771256
:py:attr:`~PIL.Image.Image.info` properties:
11781257

@@ -1188,6 +1267,11 @@ GD
11881267
Pillow reads uncompressed GD2 files. Note that you must use
11891268
:py:func:`PIL.GdImageFile.open` to read such a file.
11901269

1270+
.. _gd-opening:
1271+
1272+
Opening
1273+
~~~~~~~
1274+
11911275
The :py:meth:`~PIL.Image.open` method sets the following
11921276
:py:attr:`~PIL.Image.Image.info` properties:
11931277

@@ -1227,6 +1311,11 @@ image when first opened. The :py:meth:`~PIL.Image.Image.seek` and :py:meth:`~PIL
12271311
methods may be used to read other pictures from the file. The pictures are
12281312
zero-indexed and random access is supported.
12291313

1314+
.. _mpo-saving:
1315+
1316+
Saving
1317+
~~~~~~
1318+
12301319
When calling :py:meth:`~PIL.Image.Image.save` to write an MPO file, by default
12311320
only the first frame of a multiframe image will be saved. If the ``save_all``
12321321
argument is present and true, then all frames will be saved, and the following
@@ -1326,6 +1415,11 @@ XPM
13261415

13271416
Pillow reads X pixmap files (mode ``P``) with 256 colors or less.
13281417

1418+
.. _xpm-opening:
1419+
1420+
Opening
1421+
~~~~~~~
1422+
13291423
The :py:meth:`~PIL.Image.open` method sets the following
13301424
:py:attr:`~PIL.Image.Image.info` properties:
13311425

@@ -1350,6 +1444,11 @@ Pillow can write PDF (Acrobat) images. Such images are written as binary PDF 1.4
13501444
files, using either JPEG or HEX encoding depending on the image mode (and
13511445
whether JPEG support is available or not).
13521446

1447+
.. _pdf-saving:
1448+
1449+
Saving
1450+
~~~~~~
1451+
13531452
The :py:meth:`~PIL.Image.Image.save` method can take the following keyword arguments:
13541453

13551454
**save_all**

0 commit comments

Comments
 (0)