Patch #43932
openAdd HEIC/HEIF image support (thumbnails, inline display)
Description
Summary¶
HEIC (High Efficiency Image Codec) has been the default photo format on iOS since 2017 (iOS 11) and is increasingly used on Android. When HEIC/HEIF files are uploaded as attachments in Redmine, they are treated as generic files — no thumbnails, no inline display via !filename.heic! syntax, and no lightbox preview. This is a code-level limitation, not an ImageMagick limitation.
The official Redmine Docker image (Debian Trixie base) already ships ImageMagick with full HEIC read support via libheif. MiniMime (used by Redmine) already resolves .heic → image/heic. The only barrier is hardcoded extension and MIME type whitelists in four files.
The attached patch adds HEIC/HEIF to these whitelists following the same pattern used when WebP support was added. Thumbnails are output as JPEG (not HEIC) because ImageMagick's HEIC support is read-only — it can decode but not encode HEIC. This mirrors the existing PDF → PNG thumbnail path.
Patch is against the 6.1-stable branch (Redmine 6.1.2).
Changes¶
Four files modified, all following existing patterns:
app/models/attachment.rb— Addheicandheifto theimage?method's extension regex. Controls whether an attachment is treated as an image throughout Redmine (thumbnails, lightbox, inline display).app/helpers/application_helper.rb— Addheicandheifto the inline image rendering regex. Enables!photo.heic!syntax in issue descriptions and wiki pages. Note: HEIC renders inline in Safari (which has native HEIC decoding) but not Chrome/Firefox. This does not degrade — non-supporting browsers simply don't render the inline image, identical to current behavior for any unrecognized format.lib/redmine/thumbnail.rb— Two changes: addimage/heicandimage/heifto theALLOWED_TYPESconstant (MIME type whitelist checked before invoking ImageMagick), and add anelsifbranch in thegeneratemethod that forces JPEG output for HEIC/HEIF input using ImageMagick'sjpg:output format prefix. Without this, ImageMagick fails with "no encode delegate for this image format 'HEIC'" because its HEIC support is read-only. Follows the same pattern as the existing PDF → PNG branch.app/controllers/attachments_controller.rb— Add anelsifbranch indetect_content_typethat returnsimage/jpegfor HEIC/HEIF thumbnails. The thumbnail file contains JPEG data but the method would otherwise return the original attachment'simage/heiccontent type. Follows the existing PDF → PNG precedent.
Testing¶
Tested on Redmine 6.1.2 with ImageMagick 7.1.1-43 (libheif 1.19.8, libde265 1.0.15) and 500+ existing HEIC attachments:
- Thumbnails display correctly in issue attachment lists
- Lightbox preview works
- Inline
!photo.heic!syntax renders in Safari - No impact on existing image formats (JPEG, PNG, GIF, WebP, BMP)
- No database migration required — MiniMime already resolves the MIME type correctly
Prerequisites¶
ImageMagick must be compiled with libheif support. The official Redmine Docker images based on Debian Trixie (Redmine 5.1.12+, 6.x) include this out of the box. Verify with: convert -list format | grep -i heic — expected output includes HEIC HEIC r-- (read-only is sufficient).
Precedent¶
The WebP format was added to these same whitelists via the same mechanism. HEIC/HEIF follows the identical pattern.
Files
No data to display