Header menu logo fable-electron-docs-api

NativeImage Type

⚠ Process Availability: Main ✔ | Renderer ✔ | Utility ❌ | Exported ❌

Instance members

Instance member Description

this.addRepresentation (?scaleFactor, ?width, ?height, ?buffer, ?dataURL)

Full Usage: this.addRepresentation (?scaleFactor, ?width, ?height, ?buffer, ?dataURL)

Parameters:
    ?scaleFactor : float
    ?width : int
    ?height : int
    ?buffer : Buffer
    ?dataURL : string

Modifiers: inline

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.

?scaleFactor : float
?width : int
?height : int
?buffer : Buffer
?dataURL : string

this.crop rect

Full Usage: this.crop rect

Parameters:
Returns: NativeImage
Modifiers: inline

The cropped image.

rect : Rectangle
Returns: NativeImage

this.getAspectRatio ?scaleFactor

Full Usage: this.getAspectRatio ?scaleFactor

Parameters:
    ?scaleFactor : float

Returns: float
Modifiers: inline

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.

?scaleFactor : float
Returns: float

this.getNativeHandle ()

Full Usage: this.getNativeHandle ()

Returns: Buffer
Modifiers: inline

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌

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

Returns: Buffer

this.getScaleFactors ()

Full Usage: this.getScaleFactors ()

Returns: float[]
Modifiers: inline

An array of all scale factors corresponding to representations for a given NativeImage.

Returns: float[]

this.getSize ?scaleFactor

Full Usage: this.getSize ?scaleFactor

Parameters:
    ?scaleFactor : float

Returns: Size
Modifiers: inline

If scaleFactor is passed, this will return the size corresponding to the image representation most closely matching the passed value.

?scaleFactor : float
Returns: Size

this.isEmpty ()

Full Usage: this.isEmpty ()

Returns: bool
Modifiers: inline

Whether the image is empty.

Returns: bool

this.isMacTemplateImage

Full Usage: this.isMacTemplateImage

⚠ OS Compatibility: WIN ❌ | MAC ✔ | LIN ❌ | MAS ❌ A boolean property that determines whether the image is considered a template image.Please note that this property only has an effect on macOS.

this.isTemplateImage ()

Full Usage: this.isTemplateImage ()

Returns: bool
Modifiers: inline

Whether the image is a macOS template image.

Returns: bool

this.resize (?width, ?height, ?quality)

Full Usage: this.resize (?width, ?height, ?quality)

Parameters:
    ?width : int
    ?height : int
    ?quality : Quality

Returns: NativeImage
Modifiers: inline

The resized image.If only the height or the width are specified then the current aspect ratio will be preserved in the resized image.

?width : int
?height : int
?quality : Quality
Returns: NativeImage

this.setTemplateImage option

Full Usage: this.setTemplateImage option

Parameters:
    option : bool

Modifiers: inline

Marks the image as a macOS template image.

option : bool

this.toBitmap ?scaleFactor

Full Usage: this.toBitmap ?scaleFactor

Parameters:
    ?scaleFactor : float

Returns: Buffer
Modifiers: inline

A Buffer that contains a copy of the image's raw bitmap pixel data.

?scaleFactor : float
Returns: Buffer

this.toDataURL ?scaleFactor

Full Usage: this.toDataURL ?scaleFactor

Parameters:
    ?scaleFactor : float

Returns: string
Modifiers: inline

The Data URL of the image.

?scaleFactor : float
Returns: string

this.toJPEG quality

Full Usage: this.toJPEG quality

Parameters:
    quality : int

Returns: Buffer
Modifiers: inline

A Buffer that contains the image's JPEG encoded data.

quality : int
Returns: Buffer

this.toPNG ?scaleFactor

Full Usage: this.toPNG ?scaleFactor

Parameters:
    ?scaleFactor : float

Returns: Buffer
Modifiers: inline

A Buffer that contains the image's PNG encoded data.

?scaleFactor : float
Returns: Buffer

Type something to start searching.