Fix JPEG rotation fallback when jpegtran is unavailable and add CI support#29
Conversation
Co-authored-by: duartebarbosadev <13065435+duartebarbosadev@users.noreply.github.com>
|
@copilot Why isn't jpegtran not available? |
The CI workflow currently only installs PyQt6 system dependencies ( If you want lossless JPEG rotation in CI, you could add this to the "Install system deps" step: sudo apt-get install -y libjpeg-turbo-progsHowever, the fallback approach is still valuable since many end users might not have jpegtran installed either. The fix ensures JPEG rotation works everywhere, with lossless rotation when jpegtran is available and standard rotation as fallback. |
Lets do it! |
Co-authored-by: duartebarbosadev <13065435+duartebarbosadev@users.noreply.github.com>
Added |
now remove your change that you did on elif file_ext in self._STANDARD_PIXEL_ROTATION_FORMATS or file_ext in self._LOSSLESS_JPEG_FORMATS: the jpeg should work now without it right? |
Now that jpegtran is available in CI, JPEG files will only use the lossless rotation path and fall through to "unsupported format" if jpegtran is not available, removing the lossy fallback. Co-authored-by: duartebarbosadev <13065435+duartebarbosadev@users.noreply.github.com>
... Removed the JPEG fallback from standard pixel rotation path in commit b7dc862. Now that jpegtran is available in CI, JPEG files will only use the lossless rotation path and be treated as unsupported format if jpegtran becomes unavailable, instead of falling back to lossy pixel rotation. All rotation tests continue to pass with this change. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
The CI was failing with rotation integration tests due to JPEG files being unable to rotate when
jpegtranis not available in the system. The error was:With the underlying error:
"Failed to rotate tmpw5cp8117.jpg clockwise using unsupported format for pixel rotation method"Root Cause
In
ImageRotator.rotate_image(), whenjpegtranis not available, JPEG files would fall through to "unsupported format" because:_LOSSLESS_JPEG_FORMATSbut the conditionfile_ext in self._LOSSLESS_JPEG_FORMATS and self.jpegtran_availableevaluates toFalsewhen jpegtran is unavailable_STANDARD_PIXEL_ROTATION_FORMATSor_LOSSLESS_HEIF_FORMATSelseblock and get "unsupported format for pixel rotation"Solution
Added
libjpeg-turbo-progsto CI dependencies in.github/workflows/ci.ymlto ensure jpegtran is available during testing, enabling optimal lossless JPEG rotation in the CI environment.With jpegtran now available in CI, JPEG files use the lossless rotation path exclusively. If jpegtran becomes unavailable in any environment, JPEG files will be treated as unsupported format rather than attempting lossy fallback rotation.
Testing
The fix ensures JPEG rotation works optimally in CI while maintaining clean failure behavior when jpegtran is unavailable elsewhere.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.