novomesk / qt-avif-image-plugin

Qt plug-in to allow Qt and KDE based applications to read/write AVIF images.
BSD 2-Clause "Simplified" License
91 stars 7 forks source link

Possible small bug with QImageReader::size #7

Closed jurplel closed 3 years ago

jurplel commented 3 years ago

Hi again novomesk. This plugin is one of the most extensively developed I have seen, great work! I noticed in qView that when opening an AVIF image for the first time, the size is reported as -1, -1. After the first image is opened, the correct size is reported until the program is restarted. Are you able to reproduce this, or does this make sense in your code?

Thank you for your time.

novomesk commented 3 years ago

Hi, let's investigate this together.

First, I want to ask if you have other plug-in qt-heif-image-plugin installed? Some of the old AVIF files could be non-intentionally opened via qt-heif-image-plugin (because libheif started to support AVIF too). I know that files opened via HEIF plug-in are reported as -1 x -1 in qview. The HEIF plug-in doesn't support the Size option. So I guess that some files are opened via HEIF plug-in and some via AVIF plug-in.

Try to uninstall the qt-heif-image-plugin if you have it to make sure the files are opened only via my qt-avif-image-plugin.

If you are still able to reproduce it, send me your example collection of AVIF testfiles and show me where you are reading the size in your code and I will try to debug.

novomesk commented 3 years ago

I made following program. It opens Mexico_YUV444.avif and it should print 960x540

#include <QCoreApplication>
#include <QImage>

#include <QImageReader>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QImageReader reader("Mexico_YUV444.avif");

    if (reader.supportsOption(QImageIOHandler::Size)) {
    QSize size = reader.size();
        qWarning("%dx%d", size.width(), size.height());
    } else {
        qWarning("Size option not supported");
    }
    a.exit(0);
}
jurplel commented 3 years ago

I can confirm that removing the HEIF plugin solves the issue. Excellent work, thank you so much.

jurplel commented 3 years ago

You ever think about making a qt plugin based on libheif or forking qt-heif-image-plugin? I would like to see a version with as extensive support as you have here in qt-avif-image-plugin. It could support avif through libheif as well.

novomesk commented 3 years ago

I was thinking that qt-heif-image-plugin needs to be improved but there are still some things to be improved in libheif.

novomesk commented 3 years ago

You may take a look at https://github.com/novomesk/qt-heic-image-plugin

jurplel commented 3 years ago

Thank you, I will!