This file is indexed.

/usr/share/doc/python-willow/html/_sources/guide/open.rst.txt is in python-willow-doc 1.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Opening images
==============

Images can be either opened from a file or an existing Pillow/Wand object.

From a file
-----------

To open an image, call :meth:`Image.open` passing in a file-like object that
contains the image data.

.. code-block:: python

    from willow.image import Image

    with open('test.jpg', 'rb') as f:
        i = Image.open(f)

        isinstance(i, Image)

        from willow.image import ImageFile, JPEGImageFile
        isinstance(i, ImageFile)
        isinstance(i, JPEGImageFile)

If it succeeded, this will return a subclass of :class:`~ImageFile` (which itself
is a subclass of :class:`~Image`).

The :class:`~ImageFile` subclass it chooses depends on the format of the image (
detected by inspecting the file header). In this case, it used
:class:`~JPEGImageFile` as the image we loaded was in JPEG format.

Using different image classes for different formats allows Willow to decide
which plugin to use for performing operations on the image. For example, Willow
will always favour Wand for resizing GIF images but will always favour Pillow
for resizing JPEG and PNG images.

From an existing Pillow object
------------------------------

You can create a Willow :class:`~willow.image.Image` from an existing
``PIL.Image`` object by creating an instance of the
:class:`~willow.plugins.pillow.PillowImage` class
(passing the ``PIL.Image`` object as the only parameter):

.. code-block:: python

    from willow.plugins.pillow import PillowImage

    pillow_image = PIL.Image.open(...)

    i = PillowImage(pillow_image)

    isinstance(i, PillowImage)

    from willow.image import Image
    isinstance(i, Image)

The same can be done with Wand and OpenCV, which use the
:class:`~willow.plugins.wand.WandImage` and
:class:`~willow.plugins.opencv.OpenCVColorImage` classes respectively.