` should be replaced with any value from [ this list
](https://developer.apple.com/documentation/appkit/nsimagename?language=objc)
.

##  Class: NativeImage  â

> Natively wrap images such as tray, dock, and application icons.

Process: [ Main ](/docs/latest/glossary#main-process) , [ Renderer
](/docs/latest/glossary#renderer-process)  
_This class is not exported from the` 'electron' ` module. It is only
available as a return value of other methods in the Electron API. _

###  Instance Methods  â

The following methods are available on instances of the ` NativeImage ` class:

####  ` image.toPNG([options]) ` â

  * ` options ` Object (optional) 
    * ` scaleFactor ` Number (optional) - Defaults to 1.0. 

Returns ` Buffer ` \- A [ Buffer
](https://nodejs.org/api/buffer.html#buffer_class_buffer) that contains the
image's ` PNG ` encoded data.

####  ` image.toJPEG(quality) ` â

  * ` quality ` Integer - Between 0 - 100. 

Returns ` Buffer ` \- A [ Buffer
](https://nodejs.org/api/buffer.html#buffer_class_buffer) that contains the
image's ` JPEG ` encoded data.

####  ` image.toBitmap([options]) ` â

  * ` options ` Object (optional) 
    * ` scaleFactor ` Number (optional) - Defaults to 1.0. 

Returns ` Buffer ` \- A [ Buffer
](https://nodejs.org/api/buffer.html#buffer_class_buffer) that contains a copy
of the image's raw bitmap pixel data.

####  ` image.toDataURL([options]) ` â

  * ` options ` Object (optional) 
    * ` scaleFactor ` Number (optional) - Defaults to 1.0. 

Returns ` string ` \- The [ Data URL ](https://developer.mozilla.org/en-
US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs) of the image.

####  ` image.getBitmap([options]) ` â

  * ` options ` Object (optional) 
    * ` scaleFactor ` Number (optional) - Defaults to 1.0. 

Returns ` Buffer ` \- A [ Buffer
](https://nodejs.org/api/buffer.html#buffer_class_buffer) that contains the
image's raw bitmap pixel data.

The difference between ` getBitmap() ` and ` toBitmap() ` is that `
getBitmap() ` does not copy the bitmap data, so you have to use the returned
Buffer immediately in current event loop tick; otherwise the data might be
changed or destroyed.

####  ` image.getNativeHandle() ` _macOS_ â

Returns ` Buffer ` \- A [ Buffer
](https://nodejs.org/api/buffer.html#buffer_class_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.

####  ` image.isEmpty() ` â

Returns ` boolean ` \- Whether the image is empty.

####  ` image.getSize([scaleFactor]) ` â

  * ` scaleFactor ` Number (optional) - Defaults to 1.0. 

Returns [ Size ](/docs/latest/api/structures/size) .

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

####  ` image.setTemplateImage(option) ` â

  * ` option ` boolean 

Marks the image as a macOS [ template image
](https://developer.apple.com/documentation/appkit/nsimage/1520017-template) .

####  ` image.isTemplateImage() ` â

Returns ` boolean ` \- Whether the image is a macOS [ template image
](https://developer.apple.com/documentation/appkit/nsimage/1520017-template) .

####  ` image.crop(rect) ` â

  * ` rect ` [ Rectangle ](/docs/latest/api/structures/rectangle) \- The area of the image to crop. 

Returns ` NativeImage ` \- The cropped image.

####  ` image.resize(options) ` â

  * ` options ` Object 
    * ` width ` Integer (optional) - Defaults to the image's width. 
    * ` height ` Integer (optional) - Defaults to the image's height. 
    * ` quality ` string (optional) - The desired quality of the resize image. Possible values include ` good ` , ` better ` , or ` best ` . The default is ` best ` . These values express a desired quality/speed tradeoff. They are translated into a