Project

General

Profile

Actions

Patch #43932

open

Add HEIC/HEIF image support (thumbnails, inline display)

Added by Peter Petrik about 8 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Attachments
Target version:
-

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 .heicimage/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:

  1. app/models/attachment.rb — Add heic and heif to the image? method's extension regex. Controls whether an attachment is treated as an image throughout Redmine (thumbnails, lightbox, inline display).
  2. app/helpers/application_helper.rb — Add heic and heif to 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.
  3. lib/redmine/thumbnail.rb — Two changes: add image/heic and image/heif to the ALLOWED_TYPES constant (MIME type whitelist checked before invoking ImageMagick), and add an elsif branch in the generate method that forces JPEG output for HEIC/HEIF input using ImageMagick's jpg: 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.
  4. app/controllers/attachments_controller.rb — Add an elsif branch in detect_content_type that returns image/jpeg for HEIC/HEIF thumbnails. The thumbnail file contains JPEG data but the method would otherwise return the original attachment's image/heic content 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

Add-HEIC-HEIF-image-support.patch (2.24 KB) Add-HEIC-HEIF-image-support.patch Peter Petrik, 2026-04-06 14:18

No data to display

Actions

Also available in: Atom PDF