ColorSpace#

Properties

DeviceGray

The default Grayscale colorspace

DeviceRGB

The default RGB colorspace

DeviceBGR

The default RGB colorspace, but with components in reverse order

DeviceCMYK

The default CMYK colorspace

Lab

The default Lab colorspace

Methods

CONSTRUCTOR METHODS

ColorSpace(from: Buffer | ArrayBuffer | Uint8Array | string, name: string)#

Create a new ColorSpace from an ICC profile.

Parameters:
  • fromBuffer | ArrayBuffer | Uint8Array | string. A buffer containing an ICC profile.

  • namestring. A user descriptive name.

Returns:

ColorSpace.

EXAMPLE

let icc_colorspace = new mupdfjs.ColorSpace(fs.readFileSync("SWOP.icc"), "SWOP");

INSTANCE METHODS

getNumberOfComponents()#

A Grayscale colorspace has one component, RGB has 3, CMYK has 4, and DeviceN may have any number of components.

Returns:

number.

EXAMPLE

let cs = mupdfjs.ColorSpace.DeviceRGB;
let num = cs.getNumberOfComponents(); // 3
toString()#

Return name of ColorSpace.

Returns:

string.

EXAMPLE

var cs = mupdfjs.ColorSpace.DeviceRGB;
var name = cs.toString(); // "[ColorSpace DeviceRGB]"
isGray()#

Returns true if the object is a gray color space.

Returns:

boolean.

EXAMPLE

var bool = colorSpace.isGray();
isRGB()#

Returns true if the object is an RGB color space.

Returns:

boolean.

EXAMPLE

var bool = colorSpace.isRGB();
isCMYK()#

Returns true if the object is a CMYK color space.

Returns:

boolean.

EXAMPLE

var bool = colorSpace.isCMYK();
isIndexed()#

Returns true if the object is an Indexed color space.

Returns:

boolean.

EXAMPLE

var bool = colorSpace.isIndexed();
isLab()#

Returns true if the object is a Lab color space.

Returns:

boolean.

EXAMPLE

var bool = colorSpace.isLab();
isDeviceN()#

Returns true if the object is a Device N color space.

Returns:

boolean.

EXAMPLE

var bool = colorSpace.isDeviceN();
isSubtractive()#

Returns true if the object is a subtractive color space.

Returns:

boolean.

EXAMPLE

var bool = colorSpace.isSubtractive();
getType()#

Returns a string indicating the type.

Returns:

string.

One of:

  • “None”

  • “Gray”

  • “RGB”

  • “BGR”

  • “CMYK”

  • “Lab”

  • “Indexed”

  • “Separation”

EXAMPLE

var type = colorSpace.getType();

Code samples

Code samples are in TypeScript and assume that the following requirements are defined in your TypeScript file header as follows:

import * as fs from "fs"
import * as mupdfjs from "mupdf/mupdfjs"