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
Copyright and Attribution
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.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| random_image-0.0.8.tar.gz | 9.5 kB | With provenance | Details for random_image-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| random_image-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for random_image-0.0.8-py3-none-any.whl |
Total release size: 16.7 kB
Release files / random_image-0.0.8.tar.gz
| Download URL | random_image-0.0.8.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8303c40fe11200bc107d31ee63f571d06d747715d7ff07e12e70c6a159eb7831
|
|
BLAKE2b-256 checksum How to use checksums |
08f155775b59d8eda9cfefe7e86930202f700a796c950c5cf2606254b9b0d6f4
|
| 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 logRelease files / random_image-0.0.8-py3-none-any.whl
| Download URL | random_image-0.0.8-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f472a7f5de80d6056f15656085f464b5d9489844348d6c6860e7801199466182
|
|
BLAKE2b-256 checksum How to use checksums |
443a3120ce35152f9e8e6314b1507d9d31a7b990a8bc1ea7391184d8c9c74d39
|
| 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 logSecurity for random-image 0.0.8
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.
Attestation for random_image-0.0.8.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 logA 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.