Skip to content
Proyek

fabianwimberger/immich-convert-originals

Lihat di GitHub

Tentang

Batch-transcode Immich libraries to JPEG XL, HEIC, or AVIF (images) and AV1 (video). Save 30-50% storage. Preserves metadata & albums.

Desain dan media

Cara angka ini diukur

Yang dapat Anda lakukan

  • Asset browser — filter by type, album, archived/deleted state; thumbnails are proxied through the backend, so the API key never reaches the browser
  • Run scoping — whole library, one album, a date range, or a selection from Browse
  • Image conversion — JPEG, PNG, WebP, HEIC, AVIF, TIFF, GIF, BMP → JPEG XL, HEIC, or AVIF; JPEG → JXL is a lossless bit-exact repack; input formats can be excluded from a run
  • Video conversion — MP4, MOV, MKV → AV1 or HEVC (MP4); videos already in the target codec are skipped, and you can pick which source codecs to convert (e.g. leave AV1 sources alone when targeting HEVC)

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
+3
dalam 15 hari
+4
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Immich Library Converter

CI codecov Docker License: MIT

Disclaimer: This is an independent, community-created project. It is not affiliated with, endorsed by, or sponsored by Immich. "Immich" and its associated logos are trademarks of their respective owners. Use of the name is solely for identification and compatibility purposes. Use at your own risk.

A self-hosted, web-based tool that batch-transcodes your Immich library to modern, space-efficient formats:

  • Images → JPEG XL, HEIC, or AVIF (your choice)
  • Videos → AV1 or HEVC (MP4 container), your choice in Settings

Browse your library, pick what to convert, and watch live progress in the browser — download, transcode, upload (or save locally instead), and remove the original only once the upload is verified.

Background

JPEG XL shrinks photos by 20-40% and AV1 shrinks videos by 30-50% with no visible quality loss. On a multi-TB Immich library that adds up fast.

Desktop Mobile
Desktop web UI — asset browser Mobile web UI

Features

  • Asset browser — filter by type, album, archived/deleted state; thumbnails are proxied through the backend, so the API key never reaches the browser
  • Run scoping — whole library, one album, a date range, or a selection from Browse
  • Image conversion — JPEG, PNG, WebP, HEIC, AVIF, TIFF, GIF, BMP → JPEG XL, HEIC, or AVIF; JPEG → JXL is a lossless bit-exact repack; input formats can be excluded from a run
  • Video conversion — MP4, MOV, MKV → AV1 or HEVC (MP4); videos already in the target codec are skipped, and you can pick which source codecs to convert (e.g. leave AV1 sources alone when targeting HEVC)
  • Local-only mode — writes to <year>/<month> folders on disk instead of uploading, optionally keeping the original alongside; Immich is never touched
  • Metadata preservation — EXIF, GPS, favorite state, rating, and albums are copied to the replacement asset
  • Live and motion photos — the still is converted and stays linked to its video; motion photos with an embedded video (Google, Samsung, OnePlus) are stored as the still alone; re-encoding the video to the target codec is optional and off by default; local-only mode saves the video next to the still
  • Retry and resume — retries with more compression if the output is larger than the original; a later run skips assets already converted
  • Run history — per-asset outcomes for every run; retry only the failures or export them as CSV
  • Dry-run and live progress — preview what a run would do; progress arrives over WebSocket
  • Settings in the UI — connection, formats, quality, output mode, and retry behavior; no restart or .env file

Quick Start

Open http://localhost:8000 afterwards and enter the Immich URL and API key on the Settings page. The URL must include the /api suffix, e.g. https://photos.example.com/api.

Option 1: Prebuilt Docker Image (Recommended)

Multi-arch image (linux/amd64, linux/arm64).

mkdir -p immich-converter/data && cd immich-converter
docker run -d \
  --name immich-library-converter \
  --restart unless-stopped \
  -p 8000:8000 \
  -v ./data:/app/data \
  ghcr.io/fabianwimberger/immich-convert-originals:latest

Create data/ yourself as shown: Docker creates a missing bind-mount source as root, and the container runs as uid 1000.

Option 2: Docker Compose (Build Locally)

git clone https://github.com/fabianwimberger/immich-convert-originals.git
cd immich-convert-originals
mkdir -p data
docker compose up -d

Option 3: Local Development

Needs ffmpeg, ImageMagick with the JXL and HEIC/AVIF delegates, libjxl-tools, and exiftool on the host.

uv sync --extra dev

FRONTEND_DIR=./frontend \
DATABASE_PATH=./data/app.db \
TEMP_DIR=./data/temp \
.venv/bin/uvicorn app.main:app --app-dir backend --reload --port 8000

How It Works

flowchart LR
    A[Browse / filter library] --> B[Start a run]
    B -->|download| C[Original asset]
    C --> D{Type}
    D -->|Image| E[Image encode<br/>JXL / HEIC / AVIF]
    D -->|Video| F[AV1 or HEVC encode]
    E --> K{Output mode}
    F --> K
    K -->|Upload| G[Upload new asset]
    K -->|Local| L[Write to local disk]
    G --> H[Copy metadata<br/>EXIF, GPS, albums]
    H --> I[Delete original]
    I -.->|live progress| J[Browser via WebSocket]
    L -.->|live progress| J

Each asset is downloaded to a per-run temporary directory, transcoded (skipped if it is already in the target format), and validated; an output larger than the input is retried with more compression.

In upload mode the new asset is uploaded, its metadata is copied, and the upload is verified. Only then is the original deleted, which moves it to Immich's trash for 30 days. In local mode the file is written to <local output dir>/<year>/<month>/ and nothing in Immich changes.

If any step fails, the new asset is cleaned up and the original is preserved. The outcome is recorded either way, so a failed run shows up in History with the exact error.

Configuration

Everything behavioral — Immich connection, encoding defaults, filters, output mode — is configured from the Settings page in the web UI, no restart required. The only environment variables the app reads are infrastructure that has to exist before the database is reachable, and none of them need to be set for a normal install:

Variable Description Default
DATABASE_PATH Path to the app's SQLite database (settings + run history) /app/data/app.db
TEMP_DIR Scratch directory for in-flight downloads/transcodes /app/temp
LOG_LEVEL Log verbosity INFO
CORS_ORIGINS Comma-separated origins allowed to call the API http://localhost:8000,http://127.0.0.1:8000

Image formats

Target format decides two things: whether the pixels survive untouched, and how easily the converted original opens outside Immich once it is downloaded or shared.

Target Source pixels Opens outside Immich
JPEG XL (JXL) JPEG sources are repacked losslessly; every other source is re-encoded lossily Browsers and desktop viewers handle JXL; iOS and most Android apps do not, so a downloaded original needs another app or a converter
HEIC Always re-encoded lossily Apple devices and Windows 10+ with the HEIF codec; many Android apps and desktop viewers cannot read it
AVIF Always re-encoded lossily Current browsers and Windows 11; older viewers and some phones cannot

Within Immich all three are served through the browser's own transcoding, so the choice only shows up when an original leaves the library. Videos are always AV1 in MP4.

Custom encoder arguments

Settings → Images and Videos each have an extra-arguments field. The text is split with shell-style quoting (-set comment 'a b') and appended to the command the app builds, so the built-in flags always stay. It is never run through a shell.

Setting Tool Placed
Extra cjxl arguments cjxl, the lossless JPEG to JXL repack just before the input file
Extra ImageMagick arguments magick/convert, every other image conversion and the JPEG to JXL fallback when cjxl is missing or fails just before the output file
Extra ffmpeg arguments ffmpeg, all video conversion just before the output file

They apply to both the first pass and the retry pass, and to live photo videos when those are converted. A run started through the API can override each one with image_cjxl_args, image_magick_args or video_ffmpeg_args; an empty string means none for that run.

You are responsible for what you enter. Arguments are passed as typed, with no allowlist, and an invalid flag fails the conversion. Where a flag is given twice the tool decides which wins, and the app does not merge them: for example a custom -svtav1-params replaces the built-in HDR parameters, and a custom -map replaces the stream selection. The exact command is logged at LOG_LEVEL=DEBUG.

Security & Safety

USE AT YOUR OWN RISK. In upload mode this tool deletes originals after conversion (recoverable via Immich trash for 30 days) — always back up first and test on a small selection before converting a whole library. The web UI has no built-in authentication — it's intended for a trusted home network or behind your own reverse-proxy auth; don't expose it directly to the internet.

Troubleshooting

Symptom Cause / fix
Connection test fails with a 404 The Immich URL must point at the API root and include the /api suffix, e.g. http://immich:2283/api or https://photos.example.com/api.
Connection fails on a self-signed certificate Enable Allow insecure SSL certificates (self-signed) in Settings → Connection. This disables TLS certificate verification. Only use it for a trusted server.
Connection test or uploads fail with 401/403 The API key is missing a needed scope. Create it with asset read and asset upload permissions in Immich → Account Settings → API Keys; a read-only key authenticates but fails on upload.
Assets shared by a partner are skipped They belong to another account, so the API key can't replace them in upload mode; they're skipped instead of failing. Local output mode can still convert them.
External library assets are skipped An upload can't be written into an external library's folder. Use local output mode, or enable Convert external library assets in Settings → Output: the converted file then moves into Immich's own storage and the original is deleted from the external folder when Immich empties its trash.
Permission denied writing to /app/data The container runs as uid 1000, but a bind-mount source created by Docker is root-owned. Create the host data/ directory yourself before the first run (mkdir -p data).
Transcode fails with a codec or delegate error Local runs need ffmpeg, ImageMagick with the JXL/HEIC/AVIF delegates, libjxl-tools, and exiftool on the host. Use the Docker image to avoid host codec gaps.

Docker Image Tags

Images are available from ghcr.io/fabianwimberger/immich-convert-originals. Use latest for the latest release, or pin to a release tag without the v prefix (2, 2.10, 2.10.0).

License

MIT License — see LICENSE file.

Third-Party Licenses

Component License Source
libjxl BSD-3-Clause https://github.com/libjxl/libjxl
FFmpeg GPL-2.0+ (Alpine build links x264/x265) https://ffmpeg.org/
libheif LGPL-3.0+ https://github.com/strukturag/libheif
ImageMagick Apache-2.0 https://imagemagick.org/
ExifTool Artistic/GPL https://exiftool.org/
FastAPI MIT https://fastapi.tiangolo.com/
SQLAlchemy MIT https://www.sqlalchemy.org/

This app invokes these as separate subprocesses and never links against them, so none of the above affects this project's own MIT license. See DOCKER_LICENSES.md for the full codec library breakdown (x264, x265, libaom, dav1d, rav1e, SVT-AV1) and what GPL/LGPL requires of anyone distributing the image.

Jelajahi proyek terkait

Memuat…