[Proposal / discussion] webp_transform: serve JPEG XL (`image/jxl`) to clients that support it

未关闭
#13,771 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
活跃
技术栈
cpp
领域
networking

调研方向

Start by reviewing the webp_transform plugin and its current image/webp negotiation path, then compare the three options described in the issue. The issue is complete when the project chooses an approach, defines opt-in and precedence behavior, and agrees on dependency and encoder limits; it is currently a proposal rather than an implementation task.

由索引模型根据 Issue 内容生成。

描述

New Feature Plugins

This is a proposal for discussion, not a request to merge.

All three browser engines are turning on JPEG XL decoding by default. Chrome plans to enable it in 155 on desktop, Android and WebView. Firefox plans to enable it in 158, moved from 157. Safari 17+ has decoded still images since 2023. Each engine adds image/jxl to its image Accept header when support is on (Chromium, Gecko, WebKit). So webp_transform could negotiate JPEG XL the same way it negotiates image/webp today.

Why JPEG XL fits this plugin

When the origin image is a JPEG, libjxl can recompress it losslessly. It repacks the JPEG's existing DCT coefficients instead of decoding to pixels. The result is about 20% smaller, and the original JPEG can be rebuilt bit for bit. Today's JPEG to WebP path is a lossy re-encode.

One public data point is in ImageMagick/ImageMagick#8992. There, cjxl -j 1 recompressed an 837 KB JPEG to 655 KB. Encoding the same image losslessly from pixels produced 3.17 MB, so a lossless encode from pixels can't replace recompression. A lossy encode from pixels would be much smaller, but like WebP it can't be reversed.

The obstacle

Lossless recompression goes through the libjxl call JxlEncoderAddJPEGFrame. Neither ImageMagick nor libvips calls it: both decode to pixels and encode with JxlEncoderAddImageFrame. A reply on ImageMagick/ImageMagick#8354 points out that ImageMagick decodes every input to pixels and does not keep the compressed form. So waiting for ImageMagick to add JPEG recompression may not get us there.

Options
  1. Re-encode pixels with ImageMagick's existing JXL coder.
    • No new ATS dependency, but ImageMagick must be built with libjxl.
    • This is a lossy re-encode like WebP, so it misses the main benefit, and the encoder is slower.
  2. Call libjxl directly, for JPEG input only.
    • A small, optional code path. PNG and WebP handling stay as they are.
    • Adds libjxl (BSD-3) as an optional build dependency. libjxl in turn needs highway and brotli, and it bundles skcms (or can use lcms2) for color management.
    • Distro packages are old: EPEL 9 ships 0.7.2, while the libjxl README asks users to "update to v0.12 ASAP due to numerous security fixes". Operators would probably build libjxl themselves.
  3. Defer until users ask for it, or until a library ATS already uses supports JPEG recompression.

Any of these would need three things:

  • Opt-in. For example, a convert_to_jxl argument, so existing deployments see no change.
  • A precedence rule. Every browser that accepts JPEG XL also sends image/webp, so the plugin must pick one.
  • Encoder limits. Cap memory use and avoid a thread pool per request, because the transform runs inline on the transaction's thread.
Question

Would the project accept libjxl as an optional dependency of webp_transform (option 2), or would it prefer option 1 or 3?

主要语言
C++
星标
2k
派生
903
平均合并
4 天 4 小时
30 天内合并 PR
135

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/trafficserver 的其他 Issue

查看 apache/trafficserver 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。