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.6

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.6
File Size Uploaded Provenance Actions
random_image-0.0.6.tar.gz 9.4 kB With provenance Details for random_image-0.0.6.tar.gz

Built distribution (wheel)

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

Total release size: 16.5 kB

Release files / random_image-0.0.6.tar.gz

Download URL random_image-0.0.6.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6dc9a024356cfb6c85abb351d9c007b56ee2663df8ae86d3a91547f0e1fef498
BLAKE2b-256 checksum
How to use checksums
0f9fa5495855bc9efad692af34833244e8e97720636b17c2045fffacccff837c
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.6-py3-none-any.whl

Download URL random_image-0.0.6-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
379f8ab57eabb3f64cdb8eaac59b819d74488a73645c151506acea2674c83a23
BLAKE2b-256 checksum
How to use checksums
44c39e997f38fb03480613a2ea7547ce71c93202ae8a65e766db7a45267b5603
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.6

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.6.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