Add an image representation for a specific scale factor. This can be used to programmatically add different scale factor representations to an image. This can be called on empty images.
The image's aspect ratio (width divided by height).
If scaleFactor is passed, this will return the aspect ratio corresponding to
the image representation most closely matching the passed value.
OptionalscaleFactor: numberA Buffer that stores C pointer to underlying native handle of the image. On
macOS, a pointer to NSImage instance is returned.
Notice that the returned pointer is a weak pointer to the underlying native
image instead of a copy, so you must ensure that the associated nativeImage
instance is kept around.
An array of all scale factors corresponding to representations for a given
NativeImage.
If scaleFactor is passed, this will return the size corresponding to the image
representation most closely matching the passed value.
OptionalscaleFactor: numberWhether the image is empty.
Whether the image is a macOS template image.
The resized image.
If only the height or the width are specified then the current aspect ratio
will be preserved in the resized image.
Marks the image as a macOS template image.
A Buffer that contains a copy of the image's raw bitmap pixel data.
Optionaloptions: ToBitmapOptionsA Buffer that contains the image's JPEG encoded data.
A Buffer that contains the image's PNG encoded data.
Optionaloptions: ToPNGOptionsStaticcreateCreates an empty NativeImage instance.
StaticcreateCreates a new NativeImage instance from buffer that contains the raw bitmap
pixel data returned by toBitmap(). The specific format is platform-dependent.
StaticcreateCreates a new NativeImage instance from buffer. Tries to decode as PNG or
JPEG first.
Optionaloptions: CreateFromBufferOptionsStaticcreateCreates a new NativeImage instance from dataUrl, a base 64 encoded Data URL
string.
StaticcreateCreates a new NativeImage instance from the NSImage that maps to the given
image name. See Apple's NSImageName documentation for a list of possible
values.
The hslShift is applied to the image with the following rules:
hsl_shift[0] (hue): The absolute hue value for the image - 0 and 1 map to 0
and 360 on the hue color wheel (red).hsl_shift[1] (saturation): A saturation shift for the image, with the
following key values: 0 = remove all color. 0.5 = leave unchanged. 1 = fully
saturate the image.hsl_shift[2] (lightness): A lightness shift for the image, with the
following key values: 0 = remove all lightness (make all pixels black). 0.5 =
leave unchanged. 1 = full lightness (make all pixels white).This means that [-1, 0, 1] will make the image completely white and [-1, 1, 0] will make the image completely black.
In some cases, the NSImageName doesn't match its string representation; one
example of this is NSFolderImageName, whose string representation would
actually be NSFolder. Therefore, you'll need to determine the correct string
representation for your image before passing it in. This can be done with the
following:
where SYSTEM_IMAGE_NAME should be replaced with any value from this list.
OptionalhslShift: number[]StaticcreateCreates a new NativeImage instance from an image file (e.g., PNG or JPEG)
located at path. This method returns an empty image if the path does not
exist, cannot be read, or is not a valid image.
Staticcreatefulfilled with the file's thumbnail preview image, which is a NativeImage.
Windows implementation will ignore size.height and scale the height
according to size.width.
A
booleanproperty that determines whether the image is considered a template image.Please note that this property only has an effect on macOS.