Skip to content

Enable libjpeg-turbo jpeg7 feature to fix IMWRITE_JPEG_LUMA/CHROMA_QUALITY (fixes #1869) - #1872

Merged
shimat merged 1 commit into
mainfrom
fix_jpeg_lib_version
May 23, 2026
Merged

shimat merged 1 commit into
mainfrom
fix_jpeg_lib_version

Conversation

@shimat

@shimat shimat commented May 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds the jpeg7 feature to the libjpeg-turbo vcpkg dependency so that JPEG_LIB_VERSION is 70 on Windows and manylinux-full builds
  • Resolves the warning IMWRITE_JPEG_LUMA/CHROMA_QUALITY are not supported because JPEG_LIB_VERSION < 70
  • ImwriteFlags.JpegLumaQuality and ImwriteFlags.JpegChromaQuality now work as expected on all platforms

Root cause

OpenCV's JPEG support comes from two different sources depending on platform:

Platform JPEG source JPEG_LIB_VERSION before after
Windows x64, manylinux-full vcpkg libjpeg-turbo 62 (6b compat default) 70
Linux Docker, ARM, manylinux-slim OpenCV bundled libjpeg-turbo 70 (hardcoded in 3rdparty/libjpeg-turbo/CMakeLists.txt:137) unchanged
WASM WITH_JPEG=OFF N/A N/A

The vcpkg port for libjpeg-turbo already exposes a jpeg7 feature (-DWITH_JPEG7=ON). This PR opts in to that feature.

Notes

  • The jpeg7 feature changes the libjpeg ABI (incompatible with libjpeg 6b). Since all libraries are statically linked here, this has no impact on end users.
  • The vcpkg CI cache will be invalidated once and rebuilt automatically.
  • No source code changes — only vcpkg.json.

Fixes #1869

…CHROMA_QUALITY warning

On Windows and manylinux-full builds, OpenCV uses the vcpkg-provided
libjpeg-turbo which defaults to JPEG_LIB_VERSION 62 (libjpeg 6b compat).
IMWRITE_JPEG_LUMA/CHROMA_QUALITY require JPEG_LIB_VERSION >= 70.

Adding the `jpeg7` vcpkg feature enables WITH_JPEG7=ON, setting
JPEG_LIB_VERSION to 70 and making those flags functional.

Linux Docker and ARM builds use OpenCV's bundled libjpeg-turbo which
already hardcodes JPEG_LIB_VERSION=70, so they are unaffected.

Fixes #1869

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shimat shimat self-assigned this May 23, 2026
@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix_jpeg_lib_version

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shimat
shimat merged commit 2259c71 into main May 23, 2026
10 checks passed
@shimat
shimat deleted the fix_jpeg_lib_version branch May 23, 2026 13:01
@shimat shimat added the bug Confirmed defect in OpenCvSharp label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Confirmed defect in OpenCvSharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IMWRITE_JPEG_LUMA/CHROMA_QUALITY are not supported bacause JPEG_LIB_VERSION < 70.

1 participant