Add imagemagick-heic to the Alpine variants - #1015
Open
LeoFidjeland wants to merge 1 commit into
Open
LeoFidjeland wants to merge 1 commit into
LeoFidjeland wants to merge 1 commit into
Conversation
Alpine packages ImageMagick's coders separately and the base "imagemagick"
package ships none of them, so on the Alpine images
Imagick::queryFormats('AVIF') is empty,
WP_Image_Editor_Imagick::supports_mime_type('image/avif') returns false, and
_wp_image_editor_choose() falls back to WP_Image_Editor_GD.
That fallback is lossy: GD's imageavif() discards the ICC profile and tags the
output sRGB, so uploads carrying Adobe RGB or Display P3 profiles get
reinterpreted as sRGB and render desaturated. Nothing errors, which makes it
easy to miss - the AVIF files are produced successfully, just without their
colour information.
AV1 encoding needs no new dependency: libheif-aom comes in with
imagemagick-heic, and libavif/aom-libs are already present for GD's
--with-avif. The image grows 3 MB, from 310.4 MB to 313.4 MB.
Verified against latest/php8.3/fpm-alpine: a JPEG carrying a 560-byte Adobe RGB
profile round-trips through AVIF with the profile intact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alpine packages ImageMagick's coders as separate subpackages, and the base
imagemagickpackage ships none of them. So on the Alpine images
Imagick::queryFormats('AVIF')isempty,
WP_Image_Editor_Imagick::supports_mime_type('image/avif')returns false, and_wp_image_editor_choose()falls back toWP_Image_Editor_GD.That fallback is lossy. GD's
imageavif()discards the ICC profile and tags output assRGB, so uploads carrying Adobe RGB or Display P3 profiles get reinterpreted as sRGB and
render visibly desaturated. Nothing errors — the AVIF files are produced successfully,
just without their colour information — which makes this easy to run into without
realising. The Debian variants are unaffected, because there
libmagickcorelinks libheifdirectly.
This is the Alpine counterpart to #996 (fixed for Debian in #997). The difference is that #996 was decode-only
support failing loudly at encode time (
no encode delegate for this image format 'AVIF'),whereas here Imagick has no AVIF support at all, so it fails the editor-capability check
and WordPress quietly uses a different editor.
Before
After
Built from
latest/php8.3/fpm-alpinewith this change:AVIF encodes, and the profile survives a JPEG → AVIF conversion:
Measured mean saturation on a real Adobe RGB photograph: source JPEG 44.25%, Imagick AVIF
44.41%. The GD output the images currently produce is visibly lower.
On size
The image grows 3 MB, from 310.4 MB to 313.4 MB.
AVIF encoding needs no new heavy dependency:
libavif,aom-libsandlibdav1darealready in the image for GD's
--with-avif, andimagemagick-heicbringslibheif-aomwith it. The added weight is libheif itself (1.6 MB), libde265 (0.6 MB) and a few small
plugin shims; the ImageMagick coder module is 66 KiB.
I initially also added
libheif-x265for HEVC parity with the Debian variants after #997,but dropped it - it is 6.8 MB on its own, more than twice the cost of this fix, and HEIC
encoding is not what breaks here. Happy to add it in a follow-up if that parity is wanted.
Dockerfile.templatewas edited and./apply-templates.shrun; the 8 generatedfpm-alpineDockerfiles are the only other files changed.