danvergara / morphos

Self-hosted file converter server
MIT License
750 stars 33 forks source link

Avif #21

Closed danvergara closed 6 months ago

danvergara commented 6 months ago

Avif support

Description

The other I was scrolling through Snort and I saved a meme to later share it with friends but the format of the image was avifand I wanted to convert it to jpeg but I couldn't do that using morphos because I deferred adding avif support because I knew it would be difficult and the low hanging fruit was adding support for other formats. To put it simple, this PR adds support for the AVIF format and adds the ability to go back and forth with that format.

The biggest challenge was dealing with third-party dependencies like go-avif and libheif which both depend on external C libraries, resulting in changing the Dockerfile to install such external C libraries. The problem was that Debian package manager didn't provide the latest version of libheif library and was behind by 5 minor versions (as of the time of submitting this change latest version is 1.17.3 and on Debian bookworm the newest version available is 1.15.1), so I went ahead and switch to the Alpine image flavor as base image. Other than that, it's pretty much the same as adding support for other formats.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

First off, a change to the Ci pipeline was made as well, installing external dependencies to the test workflow, to make sure that the program compiles successfully. Second off, I added a new test case to the image package. And finally, I QA'd this change extensively, either running the server in bare metal and running it in a container.

To test it out:

  1. Locally
    $ brew install cmake make pkg-config x265 libde265 libjpeg libtool aom
    $ brew install libheif
    $ make run
  2. On a container (make sure docker is installed)
$ make docker-build
$ make docker-run

Checklist: