File: Image.rst

package info (click to toggle)
mupdf 1.27.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,224 kB
  • sloc: ansic: 335,320; python: 20,906; java: 7,520; javascript: 2,213; makefile: 1,152; xml: 675; cpp: 639; sh: 513; cs: 307; awk: 10; sed: 7; lisp: 3
file content (216 lines) | stat: -rw-r--r-- 4,587 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
.. default-domain:: js

.. highlight:: javascript

Image
=====

Constructors
------------

.. class::
	Image(pixmap, mask)
	Image(data, mask)
	Image(filename, mask)

	Create an Image and populate it with image data decoded either from a pixmap,
	a data buffer, or a file.

	:param Pixmap pixmap: A pixmap with the image data.
	:param Buffer | ArrayBuffer | Uint8Array data: Image data.
	:param string filename: Image file to load.
	:param Image mask: An optional image mask.

	.. code-block::

		var image1 = new mupdf.Image(pixmap, imagemask)
		var image2 = new mupdf.Image(buffer, imagemask)
		var image3 = new mupdf.Image("logo.png", imagemask)

Instance methods
----------------

.. method:: Image.prototype.getWidth()

	Get the image width in pixels.

	:returns: number

	.. code-block::

		var width = image.getWidth()

.. method:: Image.prototype.getHeight()

	Get the image height in pixels.

	:returns: number

	.. code-block::

		var height = image.getHeight()

.. method:: Image.prototype.getXResolution()

	Returns the x resolution for the `Image` in dots per inch.

	:returns: number

	.. code-block::

		var xRes = image.getXResolution()

.. method:: Image.prototype.getYResolution()

	Returns the y resolution for the `Image` in dots per inch.

	:returns: number

	.. code-block::

		var yRes = image.getYResolution()

.. method:: Image.prototype.getColorSpace()

	Returns the `ColorSpace` for the `Image`. Returns null if the image has
	no colors (for example if it is an opacity mask with only an alpha
	channel).

	:returns: `ColorSpace` | null

	.. code-block::

		var cs = image.getColorSpace()

.. method:: Image.prototype.getNumberOfComponents()

	Number of colors; plus one if an alpha channel is present.

	:returns: number

	.. code-block::

		var num = image.getNumberOfComponents()

.. method:: Image.prototype.getBitsPerComponent()

	Returns the number of bits per component.

	:returns: number

	.. code-block::

		var bits = image.getBitsPerComponent()

.. method:: Image.prototype.getImageMask()

	Returns ``true`` if this image is an image mask.

	:returns: boolean

	.. code-block::

		var hasMask = image.getImageMask()

.. method:: Image.prototype.getMask()

	Get another `Image` used as a mask for this one.

	:returns: `Image` | null

	.. code-block::

		var mask = image.getMask()

.. method:: Image.prototype.getInterpolate()

	|only_mutool|

	Returns whether interpolation was used during decoding.

	:returns: boolean

	.. code-block:: javascript

		var interpolate = image.getInterpolate()

.. method:: Image.prototype.getColorKey()

	|only_mutool|

	Returns an array with ``2 * getNumberOfComponents()`` integers
	for an image with color key masking, or ``null`` if masking is
	not used. Each pair of integers define an interval, and
	component values within those intervals are not painted.

	:returns: Array of number | null

	.. code-block:: javascript

		var result = image.getColorKey()

.. method:: Image.prototype.getDecode()

	|only_mutool|

	Returns an array with ``2 * getNumberOfComponents()`` numbers
	for an image with color mapping, or ``null`` if mapping is not
	used. Each pair of numbers define the lower and upper values to
	which the component values are mapped linearly.

	:returns: Array of number | null

	.. code-block:: javascript

		var arr = image.getDecode()

.. method:: Image.prototype.getOrientation()

	|only_mutool|

	Returns the orientation of the image.

	:returns: number

	.. code-block:: javascript

		var orientation = image.getOrientation()

.. method:: Image.prototype.setOrientation(orientation)

	|only_mutool|

	Set the image orientation to the given orientation.

	:param number orientation:
		Orientation value described in this table:

		======= ===========
		Value	Description
		======= ===========
		0	Undefined
		1	0 degree ccw rotation. (Exif = 1)
		2	90 degree ccw rotation. (Exit = 8)
		3	180 degree ccw rotation. (Exif = 3)
		4	270 degree ccw rotation. (Exif = 6)
		5	flip on X. (Exif = 2)
		6	flip on X, then rotate ccw by 90 degrees. (Exif = 5)
		7	flip on X, then rotate ccw by 180 degrees. (Exif = 4)
		4	flip on X, then rotate ccw by 270 degrees. (Exif = 7)
		======= ===========

.. method:: Image.prototype.toPixmap(scaledWidth, scaledHeight)

	Create a `Pixmap` from this image. The ``scaledWidth`` and
	``scaledHeight`` arguments are optional, but may be used to decode a
	down-scaled `Pixmap`.

	:param number scaledWidth:
	:param number scaledHeight:

	:returns: `Pixmap`

	.. code-block:: javascript

		var pixmap = image.toPixmap()
		var scaledPixmap = image.toPixmap(100, 100)