Skip to main content

random-image

Load a random image instantly for computer vision artisans.

Installation

Use pip:

pip install random-image

Installation From Source

git clone git@github.com:tahashieenavaz/random-image.git
pip install -e .

Configuration

The random_image() function provides several configuration options to customize image selection, output format, and dimensions.

Function Signature

def random_image(
    category: Optional[str] = None,
    as_numpy: bool = False,
    as_tensor: bool = False,
    width: int = 300,
    height: int = 300,
    download: bool = False,
    mode: str = "rgb"
):

Parameters

Parameter Type Default Description
category Optional[str] None Specifies the category from which to retrieve a random image. If omitted, an image is selected from any available category.
as_numpy bool False If True, returns the image as a NumPy array.
as_tensor bool False If True, returns the image as a PyTorch tensor.
width int 300 Specifies the desired image width in pixels.
height int 300 Specifies the desired image height in pixels.
download bool False If true the random image will be downloaded and stored with a random name.
mode str rgb Converts the image to different color modes. Available modes: rgb, rgba, gray, grayalpha, cmyk, hsv

Usage Examples

# Retrieve a random image using default settings
image = random_image()

# Retrieve an image from a specific category
image = random_image(category="nature")

# Retrieve an image as a NumPy array
image = random_image(as_numpy=True)

# Retrieve an image as a PyTorch tensor
image = random_image(as_tensor=True)

# Specify custom image dimensions
image = random_image(width=512, height=512)

# Get a random car image and save it on the disk
image = random_image(category="car", download=True)

Supported Image Classes (Categories)

  • car
  • dog
  • rabbit

All images provided by this project are sourced from Unsplash. We do not claim ownership or copyright over these images. All image rights remain with their respective original creators and are subject to Unsplash's licensing terms.

All other rights to this project are reserved by Taha Shieenavaz.

Metadata

Release files for random-image 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for random-image 0.0.4
File Size Uploaded Provenance Actions
random_image-0.0.4.tar.gz 9.2 kB With provenance Details for random_image-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for random-image 0.0.4
File Interpreter ABI Platform Actions
random_image-0.0.4-py3-none-any.whl Python 3 none any Details for random_image-0.0.4-py3-none-any.whl

Total release size: 16.2 kB

Release files / random_image-0.0.4.tar.gz

Download URL random_image-0.0.4.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
91c3806ca65e861be36d24810630e3cb3566413e9e520dbd1e848385d2b1d306
BLAKE2b-256 checksum
How to use checksums
becf4a3a27e9c2dafc279c9803ce7109ccc9295bf363558951cc4cf5471f8aa7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / random_image-0.0.4-py3-none-any.whl

Download URL random_image-0.0.4-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d1e64e7ef02840b0ec80c9f86b6f736baaf070d4f67b338dfee5643a3e0f26b
BLAKE2b-256 checksum
How to use checksums
74dd41b6133173f831ca23c4cdf6aa6a0c0426cf8188ef28b1b1658d5f357a9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for random-image 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for random_image-0.0.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page