nihui / waifu2x-ncnn-vulkan

waifu2x converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan
MIT License
3.02k stars 212 forks source link

Add support for AVIF format #191

Open rail01 opened 2 years ago

rail01 commented 2 years ago

Currently, attempt to upscale image from AVIF fails with error message:

decode image <imagename>.avif failed

While I do have libavif installed in my system.

Upscaling into AVIF also doesn't work with a different error:

invalid outputpath extension type

AVIF uses AV1 codec for compression and achieves excellent results at it. It is open-source and royalty-free. It would be great if waifu2x supported it natively.

regs01 commented 1 year ago

AVIF has a very low resolution limit - 8193x4320, as it's made for video. It can be rendered in tiles, but not perfect in that. JPEG-XL, on the other hand, is better in every way. It support resolution up to 1x1 Gp. It's still a little less than 2x2 Gp of PNG and 4x4 Gp of JPEG2000, but still quite a lot. So would make possible to use scale by 16 and 32. It also does lossless encoding better than PNG and WebP. Google is trying to sabotage it though, but hopefully it will make its way.

Disonantemus commented 10 months ago

You don't need AVIF support, you can do it now! I did a mini (simple) shell script that uses imagemagick to convert from any supported format (100+) to AVIF, and you can use it or customizing to your liking (change output format, fine tune parameters), or make it better.

#!/bin/bash
# needs installed: waifu2x-ncnn-vulkan, imagemagick

file1="${1%.*}"
mkdir -p "/tmp/waifu/"
png_in="/tmp/waifu/in.png"
png_out="/tmp/waifu/out.png"
convert "$1" "$png_in"
waifu2x-ncnn-vulkan -i "$png_in" -o "$png_out" -s 2
convert "$png_out" "$file1".avif
rm -rf "/tmp/waifu/"
shirooo39 commented 2 days ago

image I'm currently in the process of learning how to write a simple GUI using Python Eel and I tried to "implement" AVIF support by processing the image into PNG first using waifu2x and then just do a second processing using avifenc

regs01 commented 2 days ago

PNG is too large and too slow to read and write