Trilium Frontend API
    Preparing search index...

    Class NativeImage

    Index

    Constructors

    Properties

    isMacTemplateImage: boolean

    A boolean property that determines whether the image is considered a template image.

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

    darwin

    Methods

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

      Parameters

      Returns void

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

      Parameters

      • OptionalscaleFactor: number

      Returns number

    • Legacy alias for image.toBitmap().

      Parameters

      Returns void

    • 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

      darwin

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

      Returns number[]

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

      Parameters

      • OptionalscaleFactor: number

      Returns Size

    • Whether the image is empty.

      Returns boolean

    • Whether the image is a macOS template image.

      Returns boolean

    • The resized image.

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

      Parameters

      Returns NativeImage

    • Marks the image as a macOS template image.

      Parameters

      • option: boolean

      Returns void

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

      Parameters

      Returns Buffer

    • The Data URL of the image.

      Parameters

      Returns string

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

      Parameters

      • quality: number

      Returns Buffer

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

      Parameters

      Returns Buffer

    • Creates an empty NativeImage instance.

      Returns NativeImage

    • Creates a new NativeImage instance from buffer that contains the raw bitmap pixel data returned by toBitmap(). The specific format is platform-dependent.

      Parameters

      Returns NativeImage

    • Creates a new NativeImage instance from dataUrl, a base 64 encoded Data URL string.

      Parameters

      • dataURL: string

      Returns NativeImage

    • Creates 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.

      Parameters

      • imageName: string
      • OptionalhslShift: number[]

      Returns NativeImage

      darwin

    • Creates 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.

      Parameters

      • path: string

      Returns NativeImage

    • fulfilled with the file's thumbnail preview image, which is a NativeImage.

      Note

      Windows implementation will ignore size.height and scale the height according to size.width.

      Parameters

      • path: string
      • size: Size

      Returns Promise<NativeImage>

      darwin,win32