transcode-jpeg-to-jxl-lossless
Skill21 starsChanged 7 days agoMITView on GitHub
Losslessly transcode JPEG files to JPEG XL, preserving the original JPEG bitstream while achieving ~20% file size reduction. Use when archiving JPEG photo libraries where the goal is smaller files without re-compression artifacts.
- Installs packages
In this repository28 other files it gives its agents.
- ai-graphicsSkill
- auto-deskewSkill
- auto-toneSkill
- auto-white-balanceSkill
- batch-set-copyrightSkill
- check-model-pricingSkill
- convert-to-avifSkill
- fast-resizeSkill
- fast-thumbnailSkill
- from-jxlSkill
- images-to-pdfSkill
- install-depsSkill
- new-projectSkill
- new-workflowSkill
- open-workspaceSkill
- optimize-jpegSkill
- optimize-pngSkill
- pdf-extract-embedded-imagesSkill
- pdf-to-imagesSkill
- read-metadataSkill
- scrub-metadataSkill
- set-metadataSkill
- svg-to-rasterSkill
- to-jxlSkill
- upscale-imageSkill
- vectorizeSkill
- web-readySkill
- workspace-setupSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Recursive?: Ask whether to process subdirectories.
- Very specific: line 57
Use -d 0 (lossless) and a reasonable effort (suggest 6–7 for balance):
- Distinctive: line 112
No backup is created; if the originals must be preserved, the user should copy them first.
- Very specific: line 119
Selective transcoding: If you want to skip already-small files or transcode only above a size threshold, filter the find output (e.g., …
- Distinctive: line 120
Do not delete the original JPEG files automatically.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Losslessly Transcode JPEG to JPEG XL
Walk a directory of JPEG files and convert them to JPEG XL (.jxl) format using lossless encoding. cjxl automatically detects JPEG bitstream and preserves it without re-compression. Reports byte savings; explains how to recover the original JPEG if needed.
When to use
- Archiving JPEG photo libraries to save space (typically 15–25% reduction) without image degradation.
- Preparing a photo collection for long-term storage where compatibility with JPEG is not required.
- Building a smaller-footprint JXL archive that can still yield the original JPEG via
djxl --jpeg.
Inputs to gather
- Source directory — folder containing JPEG files (
.jpgor.jpeg). Default: current directory. - Recursive? Ask whether to process subdirectories. Default: no (flat, current folder only).
- Output location — optional. Default: same directory as originals (
.jxlfiles sit alongside.jpg). - Dry run first? Recommend a preview pass showing the count and byte savings estimate, before committing to the conversion.
Procedure
1. Check tooling
command -v cjxl || echo "cjxl not installed — install with: sudo apt install libjxl-tools"Abort if missing.
2. Preview
Show the user what will happen:
# Count JPEGs in scope
find <target> -maxdepth <1|999> -type f \
\( -iname '*.jpg' -o -iname '*.jpeg' \) | tee /tmp/jpegs.txt | wc -l
# Estimate original size
find <target> -maxdepth <1|999> -type f \
\( -iname '*.jpg' -o -iname '*.jpeg' \) -exec du -ch {} + | tail -1Print:
- Number of JPEG files found.
- Total original size.
- Estimated output size (advise 20% reduction as a rough baseline).
- Confirm before proceeding.
3. Transcode
Use -d 0 (lossless) and a reasonable effort (suggest 6–7 for balance):
Folder (non-recursive):
find <target> -maxdepth 1 -type f \
\( -iname '*.jpg' -o -iname '*.jpeg' \) \
-exec cjxl -d 0 -e 7 {} {.}.jxl \;Recursive:
find <target> -maxdepth 999 -type f \
\( -iname '*.jpg' -o -iname '*.jpeg' \) \
-exec cjxl -d 0 -e 7 {} {.}.jxl \;(The -d 0 flag ensures lossless encoding. Effort 7 balances speed and compression. Effort 9 is slower but slightly smaller; only recommend if the user has time.)
4. Verify and report
After transcoding:
# Count JXL files created
find <target> -maxdepth <1|999> -type f -iname '*.jxl' | wc -l
# Total size of JXL files
find <target> -maxdepth <1|999> -type f -iname '*.jxl' -exec du -ch {} + | tail -1
# Bytes saved (original size - new size)
du -ch <target> | tail -1Print:
- Files successfully transcoded.
- Original total size vs. new total size.
- Bytes saved and percentage reduction.
- Any failures (transodes that produced errors).
5. Explain recovery path
Inform the user:
If you ever need to recover the original JPEG bitstream byte-exact (for legal/archival purposes), run:
djxl --jpeg archive.jxl recovered.jpgThis works because
cjxldetected and preserved the original JPEG structure.
Output / side effects
.jxlfiles created in the source directory (or user-specified output folder).- Original
.jpgfiles remain untouched. - No backup is created; if the originals must be preserved, the user should copy them first.
Notes
- Lossless JPEG preservation:
cjxlauto-detects JPEG bitstreams and preserves them exactly. This is whydjxl --jpegcan recover the original — it's not a re-encoded approximation. - Effort 7 vs. 9: Effort 7 compresses in seconds per image; effort 9 can take minutes. For batch workflows, 7 is recommended. Use 9 only if compression size is the overriding concern.
- Size savings: Typical JPEG → JXL lossless reduction is 15–25%, depending on the original JPEG quality. Do not oversell — some JPEGs may compress only 5–10%.
- Selective transcoding: If you want to skip already-small files or transcode only above a size threshold, filter the find output (e.g.,
-size +100kfor files larger than 100 KB). - Do not delete the original JPEG files automatically. Let the user confirm removal after verifying the JXL output.
- Depends:
apt install libjxl-tools.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

