Files
romm/pyproject.toml
Sam Dornan 4393b70973 feat(media): JPEG XL library images and cover uploads (#5438)
* feat(media): serve JPEG XL library images inline

Add .jxl to the image extensions the download endpoint serves inline,
with an explicit image/jxl type since mimetypes doesn't know it, and to
the frontend lists that pick artwork and folder screenshots out of
rom.files. AVIF was already covered; the new test pins both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs

* feat(media): accept JPEG XL cover uploads through a Pillow plugin

Pillow 13 reads AVIF but not JPEG XL. pillow-jxl-plugin registers a
JXL codec with Pillow (imported once in utils/images, which the cover
and WebP-conversion code already load). It ships musllinux wheels for
the image's amd64 and arm64 builds.

ROM and collection artwork uploads now accept image/jxl and store it
re-encoded as PNG, since covers are served in their stored format and
not every browser renders JPEG XL. Avatars, stored as uploaded, keep
the PNG/JPEG/WebP/GIF allowlist.

The plugin is GPL-3.0, which is compatible with RomM's AGPL-3.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs

* test(roms): expect JPEG XL in the artwork rejection message

Artwork uploads now also accept JPEG XL, so the rejection message lists
it. The collection tests were updated with the change; this ROM one was
missed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs

* fix(media): list library JPEG XL images only where the browser renders them

Library files are served as stored, and Chrome and Firefox render no
JPEG XL, so .jxl artwork and folder screenshots showed as broken tiles
there. A one-time probe decodes a 22-byte JPEG XL image and the artwork
and screenshot lists only include .jxl files once it succeeds (Safari),
updating reactively when the answer arrives. Chromium 153 fails the
probe, so the files stay hidden there as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs

* fix(media): size-check JPEG XL before decoding and keep it out of screenshot uploads

pillow-jxl decodes every pixel in _open(), before Pillow's
decompression-bomb check sees the size, so a small, highly compressed
JXL declaring a huge canvas could exhaust memory. utils/jxl reads the
width and height from the codestream SizeHeader (bare or inside a
container) and runs Pillow's own bomb check on them first, then
registers this guarded decoder in place of the plugin's.

The decoder raises RuntimeError on a corrupt file, which escaped
store_artwork as a 500. The guard turns it into SyntaxError, so Pillow
reports UnidentifiedImageError and the upload takes the same path as a
corrupt PNG.

POST /api/screenshots validated against the library inline list, so it
started accepting .jxl, but the asset endpoint serves those as
attachments. Screenshot uploads now use their own list without JPEG XL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs

* style(media): one-sentence jxl docstring and a narrowed mock call in the JXL test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs

* style(media): one-sentence canRenderJxl doc comment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4hx1GtQiHd7vsLCpBs

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:14:06 -06:00

154 lines
3.9 KiB
TOML

[project]
name = "romm"
version = "0.0.1"
description = "A beautiful, powerful, self-hosted rom manager"
authors = [
{ name = "Zurdi", email = "zurdi@romm.app" },
{ name = "Arcane", email = "arcane@romm.app" },
{ name = "Adamantike", email = "adamantike@romm.app" },
]
requires-python = ">=3.14"
readme = "README.md"
license = "AGPL-3.0-only"
dependencies = [
"PyYAML ~= 6.0",
"SQLAlchemy[mariadb-connector,mysql-connector,postgresql-psycopg] ~= 2.1",
"Unidecode ~= 1.3",
"aiohttp ~= 3.14",
"asyncssh ~= 2.24",
"alembic ~= 1.16",
"anyio ~= 4.4",
"apprise ~= 2.0",
"authlib ~=1.9.1",
"bcrypt ~= 5.0",
"certifi >= 2026.10.19",
"colorama ~= 0.4",
"croniter ~= 6.2",
"cryptography>=49,<51",
"defusedxml ~= 0.7",
"fastapi[standard-no-fastapi-cloud-cli] ~=0.146.0",
"gunicorn ~= 26.0",
"httpx2 ~= 2.13",
"itsdangerous ~= 2.2",
"joserfc ~= 1.7.5",
"mutagen ~= 1.47",
"opentelemetry-distro ~= 0.56",
"opentelemetry-exporter-otlp ~= 1.36",
"opentelemetry-instrumentation-aiohttp-client ~= 0.56",
"opentelemetry-instrumentation-fastapi ~= 0.56",
"opentelemetry-instrumentation-httpx ~= 0.56",
"opentelemetry-instrumentation-redis ~= 0.56",
"opentelemetry-instrumentation-sqlalchemy ~= 0.56",
"pillow~=13.0",
"pillow-jxl-plugin ~= 1.3",
"psycopg[c] ~= 3.2",
"pydantic ~= 2.11",
"pydash ~= 8.0",
"python-dotenv ~= 1.2",
"python-magic ~= 0.4",
"python-socketio ~= 5.16",
"redis ~= 8.1",
"rq ~= 2.12",
"sentry-sdk ~= 2.32",
"starlette ~=1.9.0",
"streaming-form-data ~=2.1",
"ua-parser ~= 1.0",
"strsimpy ~= 0.2",
"uvicorn ~= 0.53",
"uvicorn-worker ~= 0.4",
"watchfiles ~= 1.1",
"yarl ~= 1.14",
"zipfile-inflate64 ~= 0.1",
]
[project.optional-dependencies]
dev = [
"ipdb ~= 0.13",
"ipykernel ~=7.3",
"memray ~= 1.15",
"mypy ~=2.4.0",
"pyinstrument ~= 5.0",
"types-authlib ~= 1.8.0",
"types-colorama ~= 0.4",
"types-croniter ~= 6.2",
"types-defusedxml ~= 0.7",
"types-pyyaml ~= 6.0",
]
test = [
"fakeredis ~= 2.38",
"hypothesis ~= 6.0",
"pytest ~= 9.0",
"pytest-asyncio ~= 1.1",
"pytest-cov ~=7.1",
"pytest-env ~= 1.1",
"pytest-mock ~= 3.12",
"pytest-recording ~= 0.13",
"pytest-xdist ~= 3.6",
]
[project.urls]
Homepage = "https://romm.app/"
Source = "https://github.com/rommapp/romm"
[tool.deptry]
known_first_party = [
"__version__",
"adapters",
"config",
"decorators",
"endpoints",
"exceptions",
"handler",
"logger",
"main",
"models",
"startup",
"tasks",
"utils",
]
pep621_dev_dependency_groups = ["dev"]
[tool.deptry.package_module_name_map]
PyYAML = "yaml"
opentelemetry-distro = "opentelemetry"
pillow = "PIL"
pillow-jxl-plugin = "pillow_jxl"
python-dotenv = "dotenv"
python-magic = "magic"
python-socketio = "socketio"
[tool.deptry.per_rule_ignores]
DEP002 = [ # DEP002 rule: Project should not contain unused dependencies
# Packages used within the server initialization script.
"gunicorn",
"uvicorn-worker",
"watchfiles",
# OpenTelemetry packages are used via auto-instrumentation.
"opentelemetry-exporter-otlp",
"opentelemetry-instrumentation-aiohttp-client",
"opentelemetry-instrumentation-fastapi",
"opentelemetry-instrumentation-httpx",
"opentelemetry-instrumentation-redis",
"opentelemetry-instrumentation-sqlalchemy",
# Database drivers are used via SQLAlchemy.
"psycopg",
# Pytest plugins are used via pytest only.
"pytest-cov",
"pytest-env",
"pytest-mock",
"pytest-recording",
"pytest-xdist",
]
[tool.uv]
package = false
# A range, so Dependabot's bundled uv passes; docker/Dockerfile and ./Dockerfile pin the exact version.
required-version = ">=0.13.4,<0.14"
exclude-newer = "7 days"
# Security fixes newer than the cooldown: certifi 2026.10.19 (eMudhra distrust), pillow 13.0.0
# (GHSA-8g5g-8vmr-9782). Drop each once it ages past the cooldown.
exclude-newer-package = { certifi = false, pillow = false }
[tool.ty.environment]
root = ["./backend"]