Skip to content

loadImage()

Loads an image from a specified file path. Possible image formats accepted are: .jpg, .jpeg, .png, .bpm, .tga, .hdr, .pic, .exr. Unsupported filetypes include .webp and .gif.

Alternatively, loadImage() can also take a FileData, ImageData, CompressedImageData or ByteData object via underlying Love2d framework.

Examples

loadImage example 1

local img
function setup()
  size(100, 100)
  windowTitle('loadImage example')
  -- Load the image
  img = loadImage('assets/flower.jpg')
  -- Draw the image.
  image(img, 0, 0, width, height)

  describe('Image of a pink flower in bloom.')
end

Syntax

loadImage(path)

Parameters

Parameter
path String: path of the image to be loaded or alternate love2d data object

This reference page contains content adapted from p5.js and Processing by p5.js Contributors and Processing Foundation, licensed under CC BY-NC-SA 4.0.