Python script to generate a 128x128 image from the unique hash of a file
Project description
icon-gen
Generates a deterministic 128x128 PNG icon from any file. The icon is a color grid where each square's RGB value is derived from the SHAKE-256 hash of the input file — the same file always produces the same icon.
Installation
uv sync
Usage
uv run icon-gen <filepath> [options]
Arguments
| Argument | Description |
|---|---|
filepath |
Path to the file to generate an icon for |
Options
| Option | Default | Description |
|---|---|---|
-s, --squares |
64 |
Number of squares in the grid. Must be one of: 1, 4, 16, 64 |
-n, --name |
icon.png |
Output filename. Must end in .png |
-d, --dry-run |
off | Preview the image without saving it |
Examples
# Generate icon for a file with default settings (64 squares, saved as icon.png)
uv run icon-gen myfile.bin
# 4x4 grid saved to a custom filename
uv run icon-gen myfile.bin --squares 16 --name myfile-icon.png
# Preview without saving
uv run icon-gen myfile.bin --dry-run
How it works
- The input file is hashed using SHAKE-256, producing 192 bytes of output
- The 128x128 image is divided into a square grid of
--squarescells - Each cell is filled with an RGB color taken from 3 consecutive bytes of the hash (1 byte per channel)
- The grid reads left-to-right, top-to-bottom
With 64 squares and 3 bytes per square, all 192 hash bytes are consumed exactly once — every square gets a unique RGB value.
Edge cases
--squaresmust be a power of 4 (1,4,16,64). Other values are rejected.- Output filename must end in
.png. Passing a non-.pngname raises an error before any work is done. --dry-runopens a system image viewer and does not write any file. The output of--nameis ignored in dry-run mode.- The input file must exist and be readable. If it cannot be opened, the help text is printed and the process exits.
- Icons are deterministic: the same file always produces the same icon regardless of when or where the command is run.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file icon_from_file-0.1.0.tar.gz.
File metadata
- Download URL: icon_from_file-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb503afb34e5d4314371c5795d496f25eb94de10911f81e3e4f31dc4ab21bf31
|
|
| MD5 |
ce1e52d9a6d6d645659b6448e317dc2e
|
|
| BLAKE2b-256 |
c538cece1a85cab4e8ee1070ae020113fce72de8f9377a31f02824ed181a9365
|
Provenance
The following attestation bundles were made for icon_from_file-0.1.0.tar.gz:
Publisher:
release.yml on emnul/IconGen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
icon_from_file-0.1.0.tar.gz -
Subject digest:
bb503afb34e5d4314371c5795d496f25eb94de10911f81e3e4f31dc4ab21bf31 - Sigstore transparency entry: 1385546392
- Sigstore integration time:
-
Permalink:
emnul/IconGen@75d437af4e56dd6bc389866096a9c6c50e3adaaf -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/emnul
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@75d437af4e56dd6bc389866096a9c6c50e3adaaf -
Trigger Event:
push
-
Statement type:
File details
Details for the file icon_from_file-0.1.0-py3-none-any.whl.
File metadata
- Download URL: icon_from_file-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0987b46116affcc34364baeba74dbdefd8446822d59b90a0c120ff8bb93d1c1
|
|
| MD5 |
9f88a8868167ad73dbbe6a22ff33f429
|
|
| BLAKE2b-256 |
0963befcc5cd7a4d5278fa80c74d27fdf62025b471a147a780ecf893dac857f4
|
Provenance
The following attestation bundles were made for icon_from_file-0.1.0-py3-none-any.whl:
Publisher:
release.yml on emnul/IconGen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
icon_from_file-0.1.0-py3-none-any.whl -
Subject digest:
d0987b46116affcc34364baeba74dbdefd8446822d59b90a0c120ff8bb93d1c1 - Sigstore transparency entry: 1385546396
- Sigstore integration time:
-
Permalink:
emnul/IconGen@75d437af4e56dd6bc389866096a9c6c50e3adaaf -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/emnul
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@75d437af4e56dd6bc389866096a9c6c50e3adaaf -
Trigger Event:
push
-
Statement type: