Can't load PNG to Pixbuf

Subject with GdkPixbuf.Pixbuf.new_from_stream

Can’t understand the reason, as JPEG input opening well, so problem not in code, not in buffer reading offset but maybe in some dependency not installed.

Error { domain: gdk-pixbuf-error-quark, code: 3, message: "Unrecognized image file format" }

I use Fedora 41 without any additional installations but these packages (with dependencies):

cairo-devel glib2-devel gtk4-devel libadwaita-devel pango-devel

I had same issue with webp before, but don’t remember what exactly did to add this support. Believe the problem related to package missed as maybe PNG proprietary, I don’t know…

as maybe PNG proprietary

PNG is an open format. Refer https://www.w3.org/TR/png/.

  1. Are you using a custom built gdk-pixbuf library or the one shipped with Fedora ?
  2. What’s the output of "gio info <your_png_file> | grep type" command ?
1 Like

Currently, using wrapper in Rust with following dependencies:

[dependencies.gtk]
package = "gtk4"
version = "0.9.1"
features = ["v4_10"]
  1. I’ve just installed everything from Fedora repository + rustup for wrapper
  2. The output for gio info <your_png_file> | grep type
type: regular
  standard::type: 1
  standard::content-type: image/png
  standard::fast-content-type: image/png

Strange as looks resolvable.

Maybe it’s really my fail with bytes offset in stream, just for this file, will check it later and reply, if no other ideas about library versions. Webp may cause the issues, but not on Fedora. Maybe that’s really something with URL/protocol I’m requesting this image from.

You can look into https://gitlab.gnome.org/GNOME/eog etc, to see how it load PNG images.

FWIW, png / jpeg are built into gdk-pixbuf as shown here. The rest of the supported image formats can be looked up in the following locations:

  • /usr/lib64/gdk-pixbuf-2.0/2.10.0/loaders/ ( Fedora / CentOS etc )
  • /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/ ( Debian / Ubuntu etc )

Here is the list of loaders (excluding in-built loaders) on Fedora 40:

guest@fc40:/usr/lib64/gdk-pixbuf-2.0/2.10.0/loaders/$ ls -1
libpixbufloader-ani.so
libpixbufloader-avif.so
libpixbufloader-bmp.so
libpixbufloader-gif.so
libpixbufloader-icns.so
libpixbufloader-ico.so
libpixbufloader-jxl.so
libpixbufloader-pnm.so
libpixbufloader-qtif.so
libpixbufloader-svg.so
libpixbufloader-tga.so
libpixbufloader-tiff.so
libpixbufloader-webp.so
libpixbufloader-xbm.so
libpixbufloader-xpm.so
1 Like

Yes, now I can confirm that’s my mistake (bug in code) with bytes offset just,
png loading well now.

Thanks, solved

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.