Image
¶
Image
objects are similar to Pixmaps
, but can contain compressed data.
- new Image(ref)¶
Constructor method.
Create a new image from a
Pixmap
data, or load an image file data.- Returns:
Image
.
EXAMPLE
var imageFromPixmap = new mupdf.Image(pixmap); var imageFromBuffer = new mupdf.Image(buffer);
Instance methods
- getWidth()¶
Get the image width in pixels.
- Returns:
The width value.
EXAMPLE
var width = image.getWidth();
- getHeight()¶
Get the image height in pixels.
- Returns:
The height value.
EXAMPLE
var height = image.getHeight();
- getXResolution()¶
Returns the x resolution for the
Image
.- Returns:
Int
Image resolution in dots per inch.
EXAMPLE
var xRes = image.getXResolution();
- getYResolution()¶
Returns the y resolution for the
Image
.- Returns:
Int
Image resolution in dots per inch.
EXAMPLE
var yRes = image.getYResolution();
- getColorSpace()¶
Returns the
ColorSpace
for theImage
.- Returns:
ColorSpace
.
EXAMPLE
var cs = image.getColorSpace();
- getNumberOfComponents()¶
Number of colors; plus one if an alpha channel is present.
- Returns:
Integer
.
EXAMPLE
var num = image.getNumberOfComponents();
- getBitsPerComponent()¶
Returns the number of bits per component.
- Returns:
Integer
.
EXAMPLE
var bits = image.getBitsPerComponent();
- getInterpolate()¶
Returns true if interpolated was used during decoding.
- Returns:
Boolean
.
EXAMPLE
var interpolate = image.getInterpolate();
- getColorKey()¶
Returns an array with 2 * N integers for an N component image with color key masking, or
null
if masking is not used. Each pair of integers define an interval, and component values within that interval are not painted.- Returns:
[...]
ornull
.
EXAMPLE
var result = image.getColorKey();
- getDecode()¶
Returns an array with 2 * N numbers for an N component 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:
[...]
ornull
.
EXAMPLE
var arr = image.getDecode();
- getOrientation()¶
Returns the orientation of the image.
- Returns:
Integer
.
EXAMPLE
var orientation = image.getOrientation();
- setOrientation(orientation)¶
Set the image orientation to the given orientation.
- Arguments:
orientation –
Integer
Orientation value from the table below:
0
Undefined
1
0 degree ccw rotation. (Exif = 1)
2
90 degree ccw rotation. (Exif = 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)
8
flip on X, then rotate ccw by 270 degrees. (Exif = 7)
EXAMPLE
var orientation = image.setOrientation(4);
- getImageMask()¶
Returns true if this image is an image mask.
- Returns:
Boolean
.
EXAMPLE
var mask = image.getImageMask();
- getMask()¶
Get another
Image
used as a mask for this one.- Returns:
Image
(ornull
).
EXAMPLE
var img = image.getMask();
- toPixmap(scaledWidth, scaledHeight)¶
Create a
Pixmap
from the image. ThescaledWidth
andscaledHeight
arguments are optional, but may be used to decode a down-scaledPixmap
.- Arguments:
scaledWidth –
Float
.scaledHeight –
Float
.
- Returns:
Pixmap
.
EXAMPLE
var pixmap = image.toPixmap(); var scaledPixmap = image.toPixmap(100, 100);