n algorithm-specific method that depends on the capabilities (CPU, GPU) of the underlying platform. It is possible for all three methods to be mapped to the same algorithm on a given platform. 

Returns ` NativeImage ` \- The resized image.

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

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

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

Returns ` Number ` \- 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.

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

Returns ` Number[] ` \- An array of all scale factors corresponding to
representations for a given ` NativeImage ` .

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

  * ` options ` Object 
    * ` scaleFactor ` Number (optional) - The scale factor to add the image representation for. 
    * ` width ` Integer (optional) - Defaults to 0. Required if a bitmap buffer is specified as ` buffer ` . 
    * ` height ` Integer (optional) - Defaults to 0. Required if a bitmap buffer is specified as ` buffer ` . 
    * ` buffer ` Buffer (optional) - The buffer containing the raw image data. 
    * ` dataURL ` string (optional) - The data URL containing either a base 64 encoded PNG or JPEG image. 

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.

###  Instance Properties  â

####  ` nativeImage.isMacTemplateImage ` _macOS_ â

A ` boolean ` property that determines whether the image is considered a [
template image
](https://developer.apple.com/documentation/appkit/nsimage/1520017-template) .

Please note that this property only has an effect on macOS.

[ Edit this page
](https://github.com/electron/electron/edit/main/docs/api/native-image.md)

[ Previous  MessagePortMain  ](/docs/latest/api/message-port-main) [ Next
nativeTheme  ](/docs/latest/api/native-theme)

  * Supported Formats 
  * High Resolution Image 
  * Template Image _macOS_
  * Methods 
    * ` createEmpty `
    * ` createThumbnailFromPath `
    * ` createFromPath `
    * ` createFromBitmap `
    * ` createFromBuffer `
    * ` createFromDataURL `
    * ` createFromNamedImage `
  * Class: NativeImage 
    * Instance Methods 
      * ` toPNG `
      * ` toJPEG `
      * ` toBitmap `
      * ` toDataURL `
      * ` getBitmap `
      * ` getNativeHandle `
      * ` isEmpty `
      * ` getSize `
      * ` setTemplateImage `
      * ` isTemplateImage `
      * ` crop `
      * ` resize `
      * ` getAspectRatio `
      * ` getScaleFactors `
      * ` addRepresentation `
    * Instance Properties 
      * ` isMacTemplateImage `

Docs

  * [ Getting Started ](/docs/latest/)
  * [ API Reference ](/docs/latest/api/app)

Checklists

  * [ Performance ](/docs/latest/tutorial/performance)
  * [ Security ](/docs/latest/tutorial/security)

Tools

  * [ Electron Forge ](https://electronforge.io)
  * [ Electron Fiddle ](/fiddle)

Community

  * [ Governance ](/governance)
  * [ Resources ](/community)
  * [ Discord  ](https://discordapp.com/invite/APGC3k5yaH)
  * [ Twitter  ](https://twitter.com/electronjs)
  * [ Mastodon  ](https://social.lfx.dev/@electronjs)
  * [ Stack Overflow  ](https://stackoverflow.com/questions/tagged/electron)

More

  * [ GitHub  ](https://github.com/electron/electron)
  * [ Open Collective  ](https://opencollective.com/electron)
  * [ Infrastructure Dashboard  ](https://p.datadoghq.com/sb/c44e1df0-85d7-11ee-94c9-da7ad0900002-c245f7ef47d0d0c32abecdc0938c2a85)

[ ![OpenJS Foundation Logo](/assets/img/openjsf_logo.svg) ![OpenJS Foundation
Logo](/assets/img/openjsf_logo-dark.svg) ](https://openjsf.org/)

Copyright Â© 2023 OpenJS Foundation and Electron contributors.

Hosting and infrastructure graciously