Decode HEIF images with ImageIO on macOS - #9
Conversation
4be2db8 to
122772f
Compare
HeifDecodeService keeps its libheif path and now only asks whether a platform decoder is available. All CoreFoundation and ImageIO interop lives in MacImageIoService, which reports nothing on Linux and Windows. A Mac without those frameworks now falls back to libheif. - restore the German comments this project uses in source files - run the ImageIO path under the same lock as libheif, so the application still decodes only one image at a time - pass the standard CoreFoundation callbacks to CFDictionaryCreate instead of NULL, which compared keys by pointer - drop kCGImageSourceThumbnailMaxPixelSize, leaving it out already gives the full resolution - decode into a fixed SKImageInfo so TryDecode really returns Bgra8888 on both paths - log failures instead of swallowing them in a bare Catch - keep the gallery quick preview on the plain loader with an explicit HEIF branch, so PSD is not pulled in with a different rotation rule
|
Thanks for this, and sorry for the slow reply. HEIC on macOS is a real gap and The changes are on your branch now. Please pull before you look at the diff. What I changed and whyAll the Apple interop moved into a new file, A nice side effect: because the switch is on "is the decoder available" rather The German comments are back. The project convention is English identifiers The ImageIO path now runs under the same lock as libheif. ImageIO is thread The options dictionary gets the standard CoreFoundation callbacks instead of
Failures are logged instead of being swallowed by a bare The quick preview in the gallery went back to the plain loader with an The HEIF branches in the viewer and in the shared loader stayed. Those turn What I verified hereOn Linux, with the built application: the macOS service stays completely silent What I need you to test on macOSPlease check, ideally with an iPhone photo straight off a device:
If anything there behaves differently from the version you wrote, please say so |
Summary
Use the native macOS ImageIO frameworks to decode HEIC, HEIF, and supported AVIF images, and route the gallery, viewer, and editor display paths through the existing HEIF decoding service.
Windows and Linux retain the existing optional system
libheifimplementation. No codec library is bundled, and HEIF support remains read-only.Background
FerrumPix already recognizes HEIC, HEIF, and AVIF files and includes an optional decoder based on a system-provided
libheif. On macOS, however, the application did not use the HEIF decoding support built into ImageIO.A standard macOS installation does not provide
libheif, so HEIF decoding required an additional compatible library to be installed and discoverable by the application. When that library was unavailable, FerrumPix fell back to the generic SkiaSharp/Avalonia bitmap path, which cannot decode HEIC, leaving the image unopened even though macOS itself supports the format.The decoding paths were also inconsistent. Thumbnail generation and the editor rendering pipeline could use
HeifDecodeService, while the viewer, editor display path, and gallery quick preview could still pass HEIF files directly to the unsupported generic decoder. Installinglibheiftherefore did not guarantee consistent behavior across all views.Changes
HeifDecodeService.libheifimplementation on Windows and Linux.Dependency and distribution scope
This change does not bundle
libheif, an HEVC decoder, or any other native codec dependency. It uses the decoder already provided by macOS and preserves the project's existing optional system-library policy on other platforms.It does not add HEIF encoding or in-place HEIF saving.
Testing
Tested on a Mac mini with Apple M4:
Edited-image saving was not retested because this change only replaces the source decoding path and does not modify the existing save or encoding pipeline.
The functional HEIC checks above were performed before the rebase. The rebased branch was build-verified but was not functionally retested.
Windows and Linux were not tested in this round.