...master 2026-11-10 (4e7201cfc+unstaged)

Image

Constructors

class Image(pixmap, mask)

class Image(data, mask)

class Image(filename, mask)

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

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

Instance methods

Image.prototype.getWidth()

Get the image width in pixels.

var width = image.getWidth()

Image.prototype.getHeight()

Get the image height in pixels.

var height = image.getHeight()

Image.prototype.getXResolution()

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

var xRes = image.getXResolution()

Image.prototype.getYResolution()

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

var yRes = image.getYResolution()

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).

var cs = image.getColorSpace()

Image.prototype.getNumberOfComponents()

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

var num = image.getNumberOfComponents()

Image.prototype.getBitsPerComponent()

Returns the number of bits per component.

var bits = image.getBitsPerComponent()

Image.prototype.getImageMask()

Returns true if this image is an image mask.

var hasMask = image.getImageMask()

Image.prototype.getMask()

Get another Image used as a mask for this one.

var mask = image.getMask()

Image.prototype.getInterpolate()

only mutool run

Returns whether interpolation was used during decoding.

var interpolate = image.getInterpolate()

Image.prototype.getColorKey()

only mutool run

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.

var result = image.getColorKey()

Image.prototype.getDecode()

only mutool run

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.

var arr = image.getDecode()

Image.prototype.getOrientation()

only mutool run

Returns the orientation of the image.

var orientation = image.getOrientation()

Image.prototype.setOrientation(orientation)

only mutool run

Set the image orientation to the given orientation.

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.

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