SoftCreatR / imei

IMEI - ImageMagick Easy Install
ISC License
309 stars 36 forks source link

AVIF not installed (ImageMagick 7.1.1-35 / Ubuntu 22.04.1 LTS) #115

Open jakobhaerter opened 4 months ago

jakobhaerter commented 4 months ago

I installed IMEI on a Hetzner VPS to enable full AVIF support for a website. However, ImageMagick 6.9 had a bug where PNGs with transparency were converted to AVIF files with a black background.

After successfully installing ImageMagick 7.1.1, AVIF support is completely missing. Running identify -list format does not list AVIF at all. ImageMagick 6.9 still generated AVIFs.

Any help or guidance on resolving this issue is appreciated. Thanks!

SoftCreatR commented 4 months ago

Install libavif-dev and execute IMEI with --force to perform a forced re-install.

MoritzLost commented 4 months ago

@SoftCreatR Thanks for the reply! Just tested this, unfortunately it didn't work.

First I installed libavif-dev: sudo apt install libavif-dev Then ran IMEI again with --force, which again finished successfully. But AVIF is still missing from the list of supported formats.

Weird issue, this was definitely working two weeks ago. Same server versions, same setup. We also didn't install libavif-dev. Shouldn't IMEI install the dependencies it needs, since it already does this with other required dependencies? In any case, since this still didn't work, maybe something else is going on?

SoftCreatR commented 4 months ago

libavif-dev is an exception because it doesn't exist in Ubuntu 20.04. However, until now, there was no need to install it, because it worked out of the box. I don't know, what has changed tbh. However, I am already evaluating a manual compilation/installation of libavif, even though I don't like the idea.

However, I've tested it on a fresh Hetzner VPS without any problems :S

MoritzLost commented 4 months ago

@SoftCreatR Curious – our servers are on Ubuntu 22.04.1 and it still didn't work, even after the manual installation of libavif.

Anything else we can try, or any debugging info we can provide? I don't understand the toolchain well enough to understand what's missing unfortunately.

SoftCreatR commented 4 months ago

You should check the log file.

MoritzLost commented 4 months ago

@SoftCreatR Here are the two log files from the two runs of IMEI:

imei-1721119863.log imei-1721133125.log

The first one is from the first run before I installed libavif-dev, the second one after that. Nothing sticks out to me that would explain the problem, but I'm also not sure what to look for.

SoftCreatR commented 4 months ago

From the first log:

-- Checking for module 'libavif'
--   No package 'libavif' found

From the 2nd attempt:

-- Checking for module 'libavif'
--   Found libavif, version 0.9.3

If we ignore the fact, that 0.9.3 is pretty outdated, I don't see a problem here.

MoritzLost commented 4 months ago

@SoftCreatR That's the version that's available through the PPA on Ubuntu 22.04 … 

Any idea why AVIF is still missing even though it found the lib?

SoftCreatR commented 4 months ago

Any idea why AVIF is still missing even though it found the lib?

No, because I can't reproduce that.

MoritzLost commented 4 months ago

@SoftCreatR Hm, I'm at a loss :/ Not sure what else to try, since everything seems to be working fine and we're not getting any errors. Any idea what else we can try to get to the bottom of this?

s0ar commented 4 months ago

as a workaround, using the parameter --heif-version 1.17.6 enables imagemagick with heif/heic support

from the logs: checking for libheif >= 1.4.0... yes

(the log statement "No package 'libavif' found" was always the case for me, but having heic in the delegate library configuration lets me convert avif files)

SoftCreatR commented 4 months ago

Good catch. I'll try to find out, what's changed in libheif and/or AOM.

MoritzLost commented 4 months ago

@SoftCreatR @s0ar So if I'm reading this correctly, the issue might be related to the 1.18.0 release of libheif? That would definitely fit the timeline, as our problem only started after the time of this release.

SoftCreatR commented 4 months ago

@MoritzLost Could be, yes. So you could try

./imei.sh --force --libheif-version=1.17.6

/cc @jakobhaerter

MoritzLost commented 4 months ago

@SoftCreatR Thanks, we tried this and it does fix the issue!

Good to have a workaround, but of course not a permanent solution. I'm looking at the changelog of libheif, but I don't see anything that looks related to this. Not sure why the version jump would cause this issue. Any ideas?

SoftCreatR commented 4 months ago

Not yet.

coleplx commented 2 months ago

tl;dr: Remove any pre-existing libheif.so* from your system.

That's interesting. I can reproduce the issue... sometimes.

I'm not entirely sure what causes it. Maybe previous installation's leftovers. I thought it was a bug in checkinstall, but it seems Moritz is not using it.

I created two packages, one for v1.17.6 and another one for v1.18.2, and then I extracted their files using ar -x. libheif 1.18.2

📦[coleplx@imei imei]$ ls -la /usr/local/src/
control.tar.xz                            data.tar.xz                               debian-binary                             imei-libheif_1.18.2-imei6.11.4_amd64.deb  usr/
📦[coleplx@imei imei]$ ls -la /usr/local/src/usr/local/
bin/     include/ lib/     share/   
📦[coleplx@imei imei]$ ls -la /usr/local/src/usr/local/lib/
total 4140
drwxr-xr-x. 1 root root      94 Sep 27 15:18 .
drwxr-xr-x. 1 root root      36 Sep 27 10:23 ..
drwxr-xr-x. 1 root root      14 Sep 27 11:03 cmake
-rw-r--r--. 1 root root 4237072 Sep 27 15:18 libheif.so.1.18.2
drwxr-xr-x. 1 root root      20 Sep 27 15:18 pkgconfig
drwxr-xr-x. 1 root root      28 Sep 27 15:18 x86_64-linux-gnu

libheif 1.17.6

root@ybs-customexpires-live-prod:/tmp/im7# ls -la /usr/local/src/usr/local/lib/
total 2180
drwxr-xr-x 5 root root       7 Sep 27 18:39 .
drwxr-xr-x 6 root root       6 Jul 15 15:24 ..
drwxr-xr-x 3 root root       3 Sep 25 17:19 cmake
lrwxrwxrwx 1 root root      17 Sep 25 17:26 libheif.so.1 -> libheif.so.1.17.6
-rw-r--r-- 1 root root 3924968 Sep 25 17:26 libheif.so.1.17.6
drwxr-xr-x 2 root root       3 Sep 25 17:26 pkgconfig
drwxr-xr-x 3 root root       3 Sep 25 17:26 x86_64-linux-gnu

The 1.18.2 package is missing the libheif.so.1 symlink to libheif.so.18.2. Why? I'm not entirely sure. But I reproduced this behavior a few times with v1.17.6, too. And I think it might be related to these in the logs:

/var/log/imei-1727461050.log:-- Installing: /usr/local/lib/libheif.so.1.18.2
/var/log/imei-1727461050.log:-- Up-to-date: /usr/local/lib/libheif.so.1
/var/log/imei-1727461050.log:-- Set runtime path of "/usr/local/lib/libheif.so.1.18.2" to ""
/var/log/imei-1727461050.log:-- Up-to-date: /usr/local/lib/libheif.so

The package misses libheif.so.1 everytime the log has the Up-to-date instead of Installing. I kept the original build files around and I can confirm the issue is not on cmake or libheif itself.

Check your /usr/lib, /usr/local/lib or other relevant places for already existing libheif.so and libheif.so.1.

Removing any pre-existing libheif.so file fixed the issue here.

PS: I reinstalled all the imei packages after the last test, and heif-enc complained about a missing libheif library, and magick -list formats didn't list AVIF. Running ldconfig /usr/local/lib fixed the issue. Relogging also works.

Anyway... check your heif-enc. It might give you some clues about what's wrong:

root@ybs-customexpires-live-prod:/tmp/im7# heif-enc -v
1.18.2
libheif: 1.18.2
plugin path: /usr/local/lib/libheif

Previously:

root@ybs-customexpires-live-prod:/usr/local/lib# heif-enc 
heif-enc: error while loading shared libraries: libheif.so.1: cannot open shared object file: No such file or directory
coleplx commented 1 month ago

Hey @jakobhaerter

I ran into a similar issue again today. This time, it was caused by the missing libx265 and libde265 libraries.

After I installed both libraries using apt, ImageMagick started to report HEIC, HEIF, and AVIF support again.

I know at least libjxl auto-installs missing dependencies, like libhwy. Maybe libheif used to do it, too? :shrug:

SoftCreatR commented 1 month ago

The issue is that IMEI attempts to install the packages, but it does nothing if they are already installed:

https://github.com/SoftCreatR/imei/blob/4d1c41fc0a2008d4f596cde322b3f3b83c057748/imei.sh#L571

Of course, I could force a reinstall, but that doesn’t seem like the right solution.