Add avif images in HTML using nginx as a server

*爱你&永不变心* 提交于 2021-01-28 06:23:18

问题


I created some avif images with heif-anc:

for i in card*.png ; do heif-enc "$i" -o "${i%.*}.avif" ; done

But When I added them to my website, it just proposed to download the image instead.

Then I enabled avif images in my nginx-config with

http {
  types {
    image/avif avif;
  }
  ...

Now it tries to display the image, but they seem to be broken. If you call it directly, Firefox with successfully enabled avif support shows this error message:

avif could not be displayed because it contains errors

Here: you can see the avif file I try to serve:

https://cards.incantata.de/cdn/avif_orig/card_63.avif

Do I have to create the avif image in a different way so firefox can display it?


回答1:


Firefox can't display HEIF/HEIC images yet.

In order to encode AVIF via heif-enc, add -A parameter. When you omit -A parameter, HEIC file is encoded.

Alternative way of encoding AVIF is to use avifenc from libavif package.



来源:https://stackoverflow.com/questions/65778261/add-avif-images-in-html-using-nginx-as-a-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!