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

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

Built distribution (wheel)

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

Total release size: 16.6 kB

Release files / random_image-0.0.7.tar.gz

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

Download URL random_image-0.0.7-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3348ea3613961d52bc4b8dcd513ddd0f85c6897b8f9bd9975f9e07b19a865b05
BLAKE2b-256 checksum
How to use checksums
b3f824d5aadfb001df35d843b1e0fcc9358b1bb74d06fbf719348f8884d0d728
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.7

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