Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# `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.

`DeviceLab`

> The default Lab colorspace.

Methods

new ColorSpace(from, name)

  wasm only

  Constructor method.

  Create a new `ColorSpace`.

  Arguments:

    - from – A buffer containing an ICC profile.

    - name – A user descriptive name.

  Returns:

    `ColorSpace`.

  EXAMPLE

      var icc_colorspace = new mupdf.ColorSpace(fs.readFileSync("SWOP.icc"), "SWOP");

getNumberOfComponents()

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

  EXAMPLE

      var cs = mupdf.ColorSpace.DeviceRGB;
      var num = cs.getNumberOfComponents(); // 3

toString()

  Return name of `ColorSpace`.

  Returns:

    `String`.

      var cs = mupdf.ColorSpace.DeviceRGB;
      var num = cs.toString(); // "DeviceRGB"

isGray()

  Returns true if the object is a gray color space.

  Returns:

    `Boolean`.

      var bool = colorSpace.isGray();

isRGB()

  Returns true if the object is an RGB color space.

  Returns:

    `Boolean`.

      var bool = colorSpace.isRGB();

isCMYK()

  Returns true if the object is a CMYK color space.

  Returns:

    `Boolean`.

      var bool = colorSpace.isCMYK();

isIndexed()

  Returns true if the object is an Indexed color space.

  Returns:

    `Boolean`.

      var bool = colorSpace.isIndexed();

isLab()

  Returns true if the object is a Lab color space.

  Returns:

    `Boolean`.

      var bool = colorSpace.isLab();

isDeviceN()

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

  Returns:

    `Boolean`.

      var bool = colorSpace.isDeviceN();

isSubtractive()

  Returns true if the object is a subtractive color space.

  Returns:

    `Boolean`.

      var bool = colorSpace.isSubtractive();

getType()

  Returns a string indicating the type.

  Returns:

    `String` One of “None”, “Gray”, “RGB”, “BGR”, “CMYK”, “Lab”, “Indexed”, “Separation”.

# `DefaultColorSpaces`

`DefaultColorSpaces` is an object with keys for:

getDefaultGray()

  Get the default gray colorspace.

  Returns:

    `ColorSpace`.

getDefaultRGB()

  Get the default RGB colorspace.

  Returns:

    `ColorSpace`.

getDefaultCMYK()

  Get the default CMYK colorspace.

  Returns:

    `ColorSpace`.

getOutputIntent()

  Get the output intent.

  Returns:

    `ColorSpace`.

setDefaultGray(colorspace)
  Arguments:

    - colorspace – `ColorSpace`.

setDefaultRGB(colorspace)
  Arguments:

    - colorspace – `ColorSpace`.

setDefaultCMYK(colorspace)
  Arguments:

    - colorspace – `ColorSpace`.

setOutputIntent(colorspace)
  Arguments:

    - colorspace – `ColorSpace`.