Gdk::Pixbuf does not load images

2.1k Views Asked by At

I'm trying to load a *.jpg image into a Gdk:: Pixbuf, but it fails and keeps telling me: Error interpreting JPEG image file (Wrong JPEG library version: library is 62, caller expects 80)

try{
    Gdk::Pixbuf::create_from_file(".../Test.jpg");
}
    catch(const Glib::FileError& ex) {
    std::cerr << "FileError: " << ex.what() << std::endl;
}
    catch(const Gdk::PixbufError& ex) {
    std::cerr << "PixbufError: " << ex.what() << std::endl;
}

The only installed versions are libjpeg8 and libjpeg8-dev

I have a similar problem loading .png images: GdkPixbuf-WARNING *: Bug! gdk-pixbuf loader 'png' didn't set an error on failure. PixbufError: Failed to load image '.../Test.png': reason not known, probably a corrupt image file

The libpng versions are 12-dev and 12-0

Any idea on how to fix this?

2

There are 2 best solutions below

1
On

The filename looks strange, there's one dot ore than expected. Use "../Test.jpg" instead of ".../Test.jpg".

And check your file really is a jpeg and not a png renamed as jpeg. file ../Test.jpg should tell you that.

3
On

Just really to make sure, can you post the result of:

dpkg -l | grep libjpeg

Besides that, do you have the freeimage library installed?

dpkg -l | grep libfreeimage

If so, give it try to remove this package and try your code again.

Did this help?