image(img, x, [y], [w], [h])

Adds an image to the document. If the image argument is given as a string, the path can point either directly at an image in the document’s data directory or be specified as an absolute path to the image file. The image argument can also be a File instance. The second argument can either be the x position of the frame to create or an instance of a rectangle, oval or polygon to place the image in. If an x position is given, a y position must be given, too. If x and y positions are given and width and height are not given, the frame’s size gets set to the original image size.

Type: function

Parameter(s):

  • img {String | File}:

    The image file name in the document’s data directory or a File instance.

  • x {Number | Rectangle | Oval | Polygon | TextFrame}:

    The x position on the current page or the item instance to place the image in.

  • y {Number} Optional:

    The y position on the current page. Ignored if x is not a number.

  • w {Number} Optional:

    The width of the rectangle to add the image to. Ignored if x is not a number.

  • h {Number} Optional:

    The height of the rectangle to add the image to. Ignored if x is not a number.

Returns:

  • {Rectangle | Oval | Polygon}:

    The item instance the image was placed in.