Generates a random avatar from https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar
.
Generates a random data uri containing an URL-encoded SVG image or a Base64-encoded SVG image.
Optional
options: {Options for generating a data uri.
Optional
color?: stringThe color of the image. Must be a color supported by svg.
Optional
height?: numberThe height of the image.
Optional
type?: "svg-uri" | "svg-base64"The type of the image to return. Consisting of the file extension and the used encoding.
Optional
width?: numberThe width of the image.
Generates a random square portrait (avatar) of a person. These are static images of fictional people created by an AI, Stable Diffusion 3. The image URLs are served via the JSDelivr CDN and subject to their terms of use.
Optional
options: { sex?: "female" | "male"; size?: 32 | 128 | 512 | 256 | 64 }Options for generating an AI avatar.
Optional
sex?: "female" | "male"The sex of the person for the avatar.
Can be 'female'
or 'male'
.
Optional
size?: 32 | 128 | 512 | 256 | 64The size of the image.
Can be 512
, 256
, 128
, 64
or 32
.
Generates a random image url.
Optional
options: { height?: number; width?: number }Options for generating a URL for an image.
Optional
height?: numberThe height of the image.
Optional
width?: numberThe width of the image.
Generates a random image url provided via https://loremflickr.com.
Optional
options: { category?: string; height?: number; width?: number }Options for generating a URL for an image.
Optional
category?: stringCategory to use for the image.
Optional
height?: numberThe height of the image.
Optional
width?: numberThe width of the image.
faker.image.urlLoremFlickr() // 'https://loremflickr.com/640/480?lock=1234'
faker.image.urlLoremFlickr({ width: 128 }) // 'https://loremflickr.com/128/480?lock=1234'
faker.image.urlLoremFlickr({ height: 128 }) // 'https://loremflickr.com/640/128?lock=1234'
faker.image.urlLoremFlickr({ category: 'nature' }) // 'https://loremflickr.com/640/480/nature?lock=1234'
Generates a random image url provided via https://picsum.photos.
Optional
options: {Options for generating a URL for an image.
Optional
blur?: 0 | 1 | 2 | 5 | 3 | 10 | 8 | 4 | 6 | 7 | 9Whether the image should be blurred. 0
disables the blur.
Optional
grayscale?: booleanWhether the image should be grayscale.
Optional
height?: numberThe height of the image.
Optional
width?: numberThe width of the image.
faker.image.urlPicsumPhotos() // 'https://picsum.photos/seed/NWbJM2B/640/480'
faker.image.urlPicsumPhotos({ width: 128 }) // 'https://picsum.photos/seed/NWbJM2B/128/480'
faker.image.urlPicsumPhotos({ height: 128 }) // 'https://picsum.photos/seed/NWbJM2B/640/128'
faker.image.urlPicsumPhotos({ grayscale: true }) // 'https://picsum.photos/seed/NWbJM2B/640/480?grayscale'
faker.image.urlPicsumPhotos({ blur: 4 }) // 'https://picsum.photos/seed/NWbJM2B/640/480?blur=4'
faker.image.urlPicsumPhotos({ blur: 4, grayscale: true }) // 'https://picsum.photos/seed/NWbJM2B/640/480?grayscale&blur=4'
Generates a random image url provided via https://via.placeholder.com/.
Optional
options: {Options for generating a URL for an image.
Optional
backgroundColor?: stringThe background color of the image.
Optional
format?: "gif" | "jpeg" | "jpg" | "png" | "webp"The format of the image.
Optional
height?: numberThe height of the image.
Optional
text?: stringThe text to display on the image.
Optional
textColor?: stringThe text color of the image.
Optional
width?: numberThe width of the image.
faker.image.urlPlaceholder() // 'https://via.placeholder.com/150x180/FF0000/FFFFFF.webp?text=lorem'
faker.image.urlPlaceholder({ width: 128 }) // 'https://via.placeholder.com/128x180/FF0000/FFFFFF.webp?text=lorem'
faker.image.urlPlaceholder({ height: 128 }) // 'https://via.placeholder.com/150x128/FF0000/FFFFFF.webp?text=lorem'
faker.image.urlPlaceholder({ backgroundColor: '000000' }) // 'https://via.placeholder.com/150x180/000000/FFFFFF.webp?text=lorem'
faker.image.urlPlaceholder({ textColor: '000000' }) // 'https://via.placeholder.com/150x180/FF0000/000000.webp?text=lorem'
faker.image.urlPlaceholder({ format: 'png' }) // 'https://via.placeholder.com/150x180/FF0000/FFFFFF.png?text=lorem'
faker.image.urlPlaceholder({ text: 'lorem ipsum' }) // 'https://via.placeholder.com/150x180/FF0000/FFFFFF.webp?text=lorem+ipsum'
faker.image.urlPlaceholder({ width: 128, height: 128, backgroundColor: '000000', textColor: 'FF0000', format: 'png', text: 'lorem ipsum' }) // 'https://via.placeholder.com/128x128/000000/FF0000.png?text=lorem+ipsum'
Module to generate images.
Overview
For a random image, use
url()
. This will not return the image directly but a URL pointing to an image from one of two demo image providers "Picsum" and "LoremFlickr". You can request an image specifically from one of two providers usingurlLoremFlickr()
orurlPicsumPhotos()
.For a random placeholder image containing only solid color and text, use
urlPlaceholder()
(uses a third-party service) ordataUri()
(returns a SVG string).For a random user avatar image, use
avatar()
, orpersonPortrait()
which has more control over the size and sex of the person.If you need more control over the content of the images, you can pass a
category
parameter e.g.'cat'
or'nature'
tourlLoremFlickr()
or simply usefaker.helpers.arrayElement()
with your own array of image URLs.