truist / gallery

Simple Perl-based image gallery for static images
https://gallery.rainskit.com/
MIT License
1 stars 1 forks source link

HEIF support #11

Open schmonz opened 2 years ago

schmonz commented 2 years ago

My photo-sharing workflow used to be as simple as "mount the WebDAV folder and copy some images over". I'd like to get that back.

Apple devices have defaulted to creating HEIC images for a while now. But it seems browsers generally don't ship with HEIC support. What would you suggest users do to publish such images at present -- batch-convert to JPEG before adding to the gallery?

How involved would it be to teach gallery to handle HEIF in some useful way, perhaps by automating this conversion? I see a couple imlib2 plugins that might help. Another option might be to call out to ImageMagick (which can be linked with libheif) to do the conversion.

schmonz commented 7 months ago

If .HEIC files are in a gallery directory, attempts to view the directory thumbnail gives Not a JPEG file in the logs, and attempts to browse the directory contents give 500 internal server error. Not sure which image processing code that string is coming from.

If imlib2 has been built with libheif support (PKG_OPTIONS.imlib2+=heif to us), then the imlib2_conv program can convert .HEIC to .JPG. For instance:

for i in *.HEIC; do
  j=$(basename $i .HEIC)
  imlib2_conv $j.HEIC $j.JPG && rm $j.HEIC
done

If imlib2 has not been built with libheif support, then attempting this conversion gives *** Error -2:'Imlib2: No loader for file format' loading image: and exits 1.

Conversion isn't terribly fast and doesn't offer any choice of parameters. I haven't tried to compare image quality before and after. But it seems like something we could add to gallery without requiring any new dependencies, sort of.