File: image.rst

package info (click to toggle)
python-term-image 0.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,708 kB
  • sloc: python: 8,300; makefile: 75
file content (136 lines) | stat: -rw-r--r-- 2,601 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
``image`` Module
================

.. module:: term_image.image

Functions
---------

These functions automatically detect the best supported render style for the
current terminal.

Since all classes share a common interface (as defined by :py:class:`BaseImage`),
any operation supported by one image class can be performed on any other image class,
except style-specific operations.

.. automodulesumm:: term_image.image
   :autosummary-sections: Functions
   :autosummary-no-titles:


.. autofunction:: auto_image_class

.. autofunction:: AutoImage

.. autofunction:: from_file

.. autofunction:: from_url


Enumerations
------------

.. automodulesumm:: term_image.image
   :autosummary-sections: Enumerations
   :autosummary-no-titles:


.. autoclass:: ImageSource
   :autosummary-sections: None

|

.. autoclass:: Size
   :autosummary-sections: None


.. _image-classes:

Image Classes
-------------

Class Hierarchy
^^^^^^^^^^^^^^^

* :py:class:`BaseImage`

  * :py:class:`TextImage`

    * :py:class:`BlockImage`

  * :py:class:`GraphicsImage`

    * :py:class:`ITerm2Image`
    * :py:class:`KittyImage`


The Classes
^^^^^^^^^^^

.. automodulesumm:: term_image.image
   :autosummary-sections: Classes
   :autosummary-no-titles:
   :autosummary-exclude-members: ImageIterator


.. autoclass:: BaseImage

|

.. autoclass:: TextImage

|

.. autoclass:: BlockImage

|

.. autoclass:: GraphicsImage

|

.. autoclass:: ITerm2Image

|

.. autoclass:: KittyImage

|

.. _context-manager:

Context Management Protocol Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

:py:class:`BaseImage` instances are context managers i.e they can be used with the ``with`` statement as in::

   with from_url(url) as image:
       ...

Using an instance as a context manager guarantees **instant** object **finalization**
(i.e clean-up/release of resources), especially for instances with URL sources
(see :py:meth:`BaseImage.from_url`).

|

Iteration Support
^^^^^^^^^^^^^^^^^

:term:`Animated` images are iterable i.e they can be used with the ``for`` statement (and other means of iteration such as unpacking) as in::

   for frame in from_file("animated.gif"):
       ...

Subsequent frames of the image are yielded on subsequent iterations.

.. note::
   - ``iter(anim_image)`` returns an :py:class:`ImageIterator` instance with a repeat count of ``1``, hence caching is disabled.
   - The frames are unformatted and transparency is enabled i.e as returned by ``str(image)``.

   For extensive or custom iteration, use :py:class:`ImageIterator` directly.


Other Classes
-------------

.. autoclass:: ImageIterator