Version:
class
Image
The class represents generic image data
typescript
class ImageProperties
| Name | Type | Description |
|---|---|---|
readonly bitsPerPixel | number | Number of bits per single pixel |
readonly byteWidth | number | Total number of bytes per image line |
readonly channels | number | Amount of channels |
readonly colorMode | ColorMode | An images color mode, defaults to(default: ColorMode.BGR) |
readonly data | Buffer | Generic data |
readonly height | number | height in pixels |
readonly id | string | Image identifier |
readonly pixelDensity | { scaleX: number; scaleY: number } | Object containing scale info to work with e.g. Retina display data where the reported display size and pixel size differ (Default: {scaleX: 1.0, scaleY: 1.0})(default: ...) |
readonly width | number | width in pixels |
Methods
toDataURL
toDataURL(fileType: FileType): stringencodes this as a base64 data URL string
Parameters
Returns
stringtoRGB
toRGB(): Promise<Image>converts an from BGR color mode (default within nut.js) to RGB
Returns
Promise<Image>fromRGBData
fromRGBData(width: number, height: number, data: Buffer, channels: number, id: string, bitsPerPixel: number, byteWidth: number): Imagecreates an from provided RGB data
Parameters
widthnumberheightnumberdataBufferchannelsnumberidstringbitsPerPixelnumberbyteWidthnumberReturns
ImageWas this page helpful?