Skip to main content
jpg2xlsx logo

jpg2xlsx

Turn any image into an Excel spreadsheet where every cell becomes a pixel

Create surprisingly visual .xlsx files from JPG, PNG, BMP, GIF, and other raster images supported by Pillow.

PyPI Python Tests Downloads Stars License: MIT Tweet

From image to spreadsheet art

Original input image Excel output preview

Before: a normal image
After: the same picture rebuilt as colored Excel cells


jpg2xlsx is a small Python CLI and library for generating .xlsx files from raster images. It is useful for pixel art experiments, spreadsheet demos, teaching, and weird outputs that are much more eye-catching than a normal spreadsheet should be.

Why this exists

  • Converts images into native Excel workbooks.
  • Works as both a CLI and an importable Python package.
  • Uses a simple src/ layout, uv, ruff, tests, and GitHub Actions.
  • Supports JPEG, PNG, BMP, GIF, and other formats that Pillow can read.

Install

With uv

uv tool install jpg2xlsx

With pip

pip install jpg2xlsx

CLI usage

Convert an image and write output.xlsx:

jpg2xlsx input.jpg output.xlsx

If you omit the output path, the tool writes next to the input file using the same stem:

jpg2xlsx assets/pixel-cat.png

Useful options:

jpg2xlsx input.png output.xlsx --cell-width 0.18 --cell-height 1.6 --overwrite

Compact large exports

This project writes one Excel cell per image pixel. That means file size grows quickly with image dimensions.

  • A 512x512 image becomes 262,144 formatted cells.
  • More cells means more worksheet XML inside the .xlsx file.
  • More unique colors usually means more cell formats too.

So a large image producing a workbook around 1.5 MB is not unusual for this output model.

If you want smaller .xlsx files, reduce one or both of these before export:

  • Total pixels with --max-dimension
  • Color variety with --colors

Recommended commands:

jpg2xlsx image.png output.xlsx --max-dimension 256 --colors 64
jpg2xlsx image.png output.xlsx --max-dimension 128 --colors 32
jpg2xlsx image.png output.xlsx --max-dimension 384 --colors 128

Practical guidance:

  • Use --max-dimension 128 --colors 32 when file size matters more than fidelity.
  • Use --max-dimension 256 --colors 64 as a balanced default for big images.
  • Use --max-dimension 384 --colors 128 when you want to preserve more detail.

Option reference:

  • --max-dimension: downscales the image so its largest side matches the given value before generating the workbook.
  • --colors: reduces the image palette to the given number of colors, from 1 to 256.

Run help:

jpg2xlsx --help

Running in development

If you are running from the source tree, prefer module or script entrypoint execution instead of calling the package directory directly.

Correct:

uv run jpg2xlsx input.png output.xlsx
uv run python -m jpg2xlsx input.png output.xlsx

Incorrect:

uv run python src/jpg2xlsx

That direct directory execution does not establish package context correctly in Python, so relative imports can fail.


Python usage

from jpg2xlsx import convert

convert("input.jpg", "output.xlsx")

You can also use the compacting options from Python:

from jpg2xlsx import convert

convert(
    "input.jpg",
    "output.xlsx",
    max_dimension=256,
    colors=64,
)

Development

uv sync --all-groups
uv run ruff check .
uv run ruff format --check .
uv run pytest

Release flow

  • CI runs lint, tests, and package builds on pushes and pull requests.
  • Version bump workflows use Commitizen and update the changelog.
  • Publish workflows build with uv and upload to PyPI or TestPyPI.

Contributing

See CONTRIBUTING.md for local setup and contribution guidelines.

Security

See SECURITY.md for vulnerability reporting.

License

This project is licensed under the MIT License.


⭐ If jpg2xlsx made you smile, a star helps others discover it

GitHub stars

⭐ Star on GitHub


Star History

Star History Chart

Metadata

Release files for jpg2xlsx 0.2.1

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

Source distribution (sdist)

Source distribution for jpg2xlsx 0.2.1
File Size Uploaded
jpg2xlsx-0.2.1.tar.gz 2.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for jpg2xlsx 0.2.1
File Interpreter ABI Platform
jpg2xlsx-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 2.5 MB

Release files / jpg2xlsx-0.2.1.tar.gz

Download URL jpg2xlsx-0.2.1.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
f19b407c834a31d86d6b7ad235d2f79e8e157be107613c995086685516a719d8
BLAKE2b-256 checksum
How to use checksums
c3215208d4909d2e877394058c55f0fa844eac5a8657330294d6fbf0b021c72b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / jpg2xlsx-0.2.1-py3-none-any.whl

Download URL jpg2xlsx-0.2.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44969f60bbb1fe07b08bb50b62fcea7f9c1d5ad68bda5d28fdcca3f0724c1f3f
BLAKE2b-256 checksum
How to use checksums
4cd527abf09b50a8e10db6143915e9ae2e8694635f229d5d39f427e443113e0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

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