strukturag / heif-gimp-plugin

Plugin for GIMP to load HEIF files.
GNU General Public License v2.0
26 stars 6 forks source link

Add discovery of decoding/encoding heif support #4

Open Jehan opened 6 years ago

Jehan commented 6 years ago

Followup of issue #3. In GIMP, all we can do right now is to write down in INSTALL that libheif must be compiled with libx265 and libde265 support. It would be nice if we could instead "discover" at configuration time.

The common way to do so is by the pkg-config .pc file. Either you could add some pkg-config variable telling us whether the encoding or decoding are built-in. Or simply you can create more pc files. Like libheif-encoder.pc and libheif-decoder.pc (I am assuming here these 2 libs are only used for encoding and decoding).

farindk commented 6 years ago

I would prefer to check at runtime what is available and only register those parts of the plugin. Especially if we are going to add support for more formats, like AV1, doing this at configuration time would increasingly complicate things.

Jehan commented 6 years ago

It can be both. Having runtime checks is good too but it would be nice to be able to check somehow that libheif can actually encode/decode heif files. This is typically a case where we could create packages containing a broken HEIF plugin without even realizing it because the configure showed that everything was all right.

fancycode commented 6 years ago

Keep in mind that libheif could be different at runtime compared to libheif during build-time and the list of supported codecs might be different. Also applications can register external codecs, so a codec might not be there during build-time, but is available later in the application.

I'm +1 with @farindk for checking at runtime.

If you really want to do it at build-time, you could use AC_RUN_IFELSE to build and run a small application in configure and check if a given codec is available.

farindk commented 6 years ago

I understand that you might want to check for support already at configure time. Hence, I've added (commit 9031b53 in libheif) two pkg-config variables "builtin_h265_decoder" and "builtin_h265_encoder" that you can check for. I'll also going to add the runtime check too.

Jehan commented 6 years ago

Thanks @fancycode and @farindk.

I would have settled indeed for a AC_RUN_IFELSE check but I don't like these for the very simple reason that they don't work when cross-compiling (so you end-up tweaking your configure script special-casing cross-compilation, etc.). I prefer very much having pkg-config variables. That's great!

farindk commented 6 years ago

I have added two API functions for simple testing at runtime whether there is encoding/decoding support: int heif_have_decoder_for_format(enum heif_compression_format format) int heif_have_encoder_for_format(enum heif_compression_format format)

Jehan commented 6 years ago

Awesome, thanks @farindk. I would like to propose to close this report when you announce a new release of libheif because we can't update our code based on non-released versions. Or if you prefer, you can close here and we would appreciate if you could make a comment on our side's report to tell us the release has been done. One way or another. Otherwise I will forget! :P

P.S.: also sorry, I just realized I reported on the wrong project. I should have reported this in the libheif project actually!

farindk commented 6 years ago

Yes, I thought so. I made a fork of gimp with the changes here https://gitlab.gnome.org/farindk/gimp/tree/changes-for-libheif-v1.3.0 and will send you a pull-request when everything is ready and released. (Still working on other things like saving thumbnails and saving Exif.)

Jehan commented 6 years ago

and will send you a pull-request when everything is ready and released.

Ah awesome. Then you may just close this report if you want. I just wanted to keep something somewhere to send me notifications so that I don't forget. But if you take care of contributing a MR, then I will also get my notification and even won't have to code anything! :-)

KrasnayaPloshchad commented 6 years ago

This support would be nice choice if you are installed the following plugins from MS Store: https://www.microsoft.com/store/productId/9PMMSR1CGPWG https://www.microsoft.com/store/productId/9NMZLZ57R3T7 https://www.microsoft.com/store/productId/9N4WGH0Z6VHQ