如何将 avif 图像文件转换为 png 文件?

如何将 avif 图像文件转换为 png 文件?

如何将 avif 图像文件转换为 png 文件?

$ convert macadamiaCracker1.{avif,png}
convert: Decoder plugin generated an error: Unspecified (7.0) `macadamiaCracker1.avif' @ error/heic.c/IsHEIFSuccess/135.
convert: no images defined `macadamiaCracker1.png' @ error/convert.c/ConvertImageCommand/3325.

在哪里

$ file macadamiaCracker1.avif
macadamiaCracker1.avif: ISO Media, AVIF Image

ImageMagick 7.1.0-45 之后是否convert 更新以支持 avif?

$ convert --version
Version: ImageMagick 7.1.0-45 Q16-HDRI x86_64 d80f6a7cd:20220731 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fontconfig freetype heic jng jp2 jpeg jxl lcms lqr lzma openexr png raw rsvg tiff webp x xml zlib
Compiler: gcc (11.3)

答案1

检查文件是否为 avif。如果 FILE.avif 是 avif,则结果file FILE.avif应为:

FILE.avif: ISO Media, AVIF Image

将单个文件从 avif 转换为 png:

convert FILE.avif FILE.png

将目录中的所有 .avif 文件从 avif 转换为 png:

for image in *.avif ;  do convert "$image" "${image%.*}.png" ; done

答案2

即使你已经拥有,convert你也需要运行此安装

sudo apt install imagemagick

然后重新运行你的convert命令

在运行上述安装之前我遇到了同样的错误...当时我的convert版本是

...................................

convert -version
GraphicsMagick 1.3.38 2022-03-26 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2022 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.

Feature Support:
  Native Thread Safe         yes
  Large Files (> 32 bit)     yes
  Large Memory (> 32 bit)    yes
  BZIP                       yes
  DPS                        no
  FlashPix                   no
  FreeType                   yes
  Ghostscript (Library)      no
  HEIF/HVEC ("HEIC")         yes
  JBIG                       yes
  JPEG-2000                  no
  JPEG                       yes
  JPEG XL                    no
  Little CMS                 yes
  Loadable Modules           no
  Solaris mtmalloc           no
  Google perftools tcmalloc  no
  OpenMP                     yes (201511 "4.5")
  PNG                        yes
  TIFF                       yes
  TRIO                       no
  Solaris umem               no
  WebP                       yes
  WMF                        yes
  X11                        yes
  XML                        yes
  ZLIB                       yes

Host type: x86_64-pc-linux-gnu

Configured using the command:
  ./configure  '--build' 'x86_64-linux-gnu' '--enable-shared' '--enable-static' '--enable-libtool-verbose' '--prefix=/usr' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--docdir=${prefix}/share/doc/graphicsmagick' '--with-gs-font-dir=/usr/share/fonts/type1/gsfonts' '--with-x' '--without-dps' '--without-modules' '--without-frozenpaths' '--with-webp=yes' '--with-zstd=yes' '--with-perl' '--with-perl-options=INSTALLDIRS=vendor' '--enable-quantum-library-names' '--with-quantum-depth=16' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -ffile-prefix-map=/build/graphicsmagick-vK5lFw/graphicsmagick-1.4+really1.3.38=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security' 'LDFLAGS=-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -ffile-prefix-map=/build/graphicsmagick-vK5lFw/graphicsmagick-1.4+really1.3.38=. -flto=auto -ffat-lto-objects -flto=a

Final Build Parameters:
  CC       = gcc
  CFLAGS   = -fopenmp -g -O2 -ffile-prefix-map=/build/graphicsmagick-vK5lFw/graphicsmagick-1.4+really1.3.38=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall
  CPPFLAGS = -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/libxml2
  CXX      = g++
  CXXFLAGS = -g -O2 -ffile-prefix-map=/build/graphicsmagick-vK5lFw/graphicsmagick-1.4+really1.3.38=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security
  LDFLAGS  = -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now
  LIBS     = -ljbig -lwebp -lwebpmux -lheif -lde265 -llcms2 -ltiff -lfreetype -ljpeg -lpng16 -lwmflite -lXext -lSM -lICE -lX11 -llzma -lbz2 -lxml2 -lz -lzstd -lm -lpthread

................................

然而运行上述安装后它现在显示

convert -version
Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(4.5) 
Delegates (built-in): bzlib djvu fftw fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib

答案3

如果你不介意使用 GUI 程序,那么GIMP

相关内容