Using the code provided by @Zenja in another post for decoding HEIC images, I have put together a very basic image translator, making it possible to read .heic files in Haiku.
Thanks Johan for taking the effort to make an image translator. I can confirm that it works when I manually assign an images FileType
There is a fix you will need to do to fix images with stride problems. See code below for fix. I will have to upload an HEIC image to another site for you to test with since this forum doesn’t allow uploading HEIC images (I cannot upload right now from Iceweasel/epiphany/web+ since they’re all crashing on me today, so reboot needed to upload),.
With the translator wihtout the stride fix, it will crash, but if you put the stride code as below, it will work.
Thanks for your detailed answer and the fix, and for providing the image. I updated my code and it seems to work great. Your image caused Tracker to crash before updating the code, now the image loads without problems.
Thanks, looks great. I was able to register mime/heic on my system using DarkWyrm’s tutorial, but this looks quite different. I’ve got some new concepts to learn…
Question: How can I un-register a mime type, so I can test the installation multiple times?
R/W location of mime_db seems to be: /boot/home/config/settings/mime_db. IIRC, while testing things I just had to remove mime_db/application/x-squashfs-image from there, and reboot (not sure if restarting registrar is possible or enough).
(I remember I had to remove more than once application/x-vnd.ram-beezer for example, while adding .hpkg and squashfs support for it )
And yes, for native stuff I guess using proper API makes sense. In my case, as squasfs-tools was more of straight port, using this method was the easiest for me.
(just brought this topic after reading some comments on the “how to set default apps” thread, that reminded me I had to do quite some trial and error until I got it working right for squashfs-tools).
Not really, because it means your application (or add-on) code has to be run once for the type to be registered. Sometimes it’s simpler to just provide the MimeDB type file already ready to use.
I’m not sure if translators get a chance to register a MIME type at some point when they are initialized?
I just updated the translator, it now uses code similar to the EXR translator. Using other examples I created my first recipe for this (PR pending approval), which also should register a MIME type for .heic and .heif images.
The translator works right away, but a reboot seems to be required for the MIME type to be fully recognized (and HEIC images to show up in FileTypes).
Maybe there’s a better way to register the type so it shows up instantly?
Thanks Johan for making the effort. From my Gallery image/video viewing app I’ll remove the custom heic decoder and rely on your translator being present in Haiku.
Will do when ready (open source). Right now, Haiku nightly images have ffmpeg 5 crashes and btranslator crashes (I’ve logged the issues in bugtracker) which do not exist in earlier betas (most of us are on nightly). The app generates thumbnails on the fly (modern CPU’s can decode fast enough to bypass the need to cache decoded images) and parses video frames on many threads, so lots of simultaneous access to ffmpeg internals which reveal issues.
The primary goal of the app is to show thumbnails from multiple sources (images and video, in many directories and drive volumes), because who knows where the Fiji holiday photos are saved. And while navigating you get distracted and decide to slide show your Thailand holiday instead. And watch videos from the trip. With silly transitions for cinematic transitions, and slight pans/zooms while viewing images.
All native code (BTranslators and BMediaKit). Will publish when stable.