Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt- unable to save jpeg files

Tags:

qt

I am trying to save images in Qt. I am able to save all the formats except jpeg. I have the following libraries under the plugins/imageformats folder.

libqgif.so, libqjpeg.so.

Do I have to place them in a different folder to make this work? Is there any new libraries that I have to install to make this work. I work on linux platform and my application is supported on all linux platforms. So do I have to install separate libraries for each platform?

Thanks,

like image 585
santhosh Avatar asked Dec 17 '22 10:12

santhosh


2 Answers

You might find what the problem is by:

  • Setting the environment variable QT_DEBUG_PLUGINS to 1 before running your application.
    It will print the plugin loading attempts/successes/failures on the console.

  • Using a QImageWriter to get a more explicit error message than with just QImage::save or QPixmap::save :

    QImageWriter writer("/tmp/test.jpg");
    if(!writer.write(pixmap.toImage()))
    {
        qDebug() << writer.errorString();
    }
    
like image 101
alexisdm Avatar answered Jan 10 '23 09:01

alexisdm


Under windows the qjpeg4.dll must in a imageformats directory under the application's directory by default.

like image 22
Martin Beckett Avatar answered Jan 10 '23 09:01

Martin Beckett