Edit in GitHubLog an issue

ImageFill

Kind: class

ImageFill represents a bitmap (raster) image that can be used as the fill property of any shape node (but not Artboards). The supported image encodings are: PNG, JPEG, and GIF.

Example

Copied to your clipboard
1// User picks an image file
2const storage = require("uxp").storage;
3const fs = storage.localFileSystem;
4let imageFile = await fs.getFileForOpening({ types: storage.fileTypes.images });
5
6// Create ImageFill for this image
7const ImageFill = require("scenegraph").ImageFill;
8let fill = new ImageFill(imageFile);
9
10// Set fill of first selected item
11selection.items[0].fill = fill;

new ImageFill()

new ImageFill(fileOrDataURI): ImageFill

ParamTypeDescription
fileOrDataURI
uxp.storage.File or string
File object pointing to an image file; or a string containing a data: URI with a base-64 encoded image.

clone()

clone(): ImageFill

Returns a new copy of this ImageFill.

Kind: instance method of ImageFill

assetId

assetId: string

Since: XD 29

A unique identifier for the image asset used by this ImageFill. May be shared by other ImageFills, including those with different cropping, size, rotation, or mirroring. If identical images are imported into XD from separate sources, they may have different assetIds however.

Kind: instance property of ImageFill

scaleBehavior

scaleBehavior: string

Default: SCALE_COVER

How the image is scaled when the aspect ratio of the shape does not match the aspect ratio of the image:

  • ImageFill.SCALE_COVER - The image's aspect ratio is preserved and it is scaled to completely cover the area of the shape. This means on one axis the image's edges line up exactly with the edges of the shape, and on the other axis the image extends beyond the shape's bounds and is cropped. (Similar to object-fit: cover in CSS).
  • ImageFill.SCALE_STRETCH - The image is stretched (distorting its aspect ratio) so its edges line up exactly with the edges of the shape. (Similar to object-fit: fill in CSS).

Image size and scaling are also affected by cropping settings, but these are not yet exposed to plugins.

Kind: instance property of ImageFill

naturalWidth

naturalWidth: number

Pixel dimensions of the underlying bitmap image data.

Kind: instance property of ImageFill Read only: true

naturalHeight

naturalHeight: number

Pixel dimensions of the underlying bitmap image data.

Kind: instance property of ImageFill Read only: true

mimeType

mimeType: string

Format the image data was originally encoded in, such as image/gif or image/jpeg.

Kind: instance property of ImageFill Read only: true

isLinkedContent

isLinkedContent: boolean

True if the image comes from a link to an external resource, such as Creative Cloud Libraries.

Kind: instance property of ImageFill Read only: true

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2023 Adobe. All rights reserved.