Search code examples
pythonpygtk

Save gtk Pixbuf as a jpg


I have a Pixbuf object pb.

If I try to save as a jpg I get an error:

pb = pb.get_from_drawable(w, w.get_colormap(), 0, 0, 0, 0, sz[0], sz[1])
pb.save("screenshot.jpg", "jpg")

The error I get is:

glib.GError: image not supported

If I try to save as a png it works:

pb = pb.get_from_drawable(w, w.get_colormap(), 0, 0, 0, 0, sz[0], sz[1])
pb.save("screenshot.png", "png")

How can I save the image in jpg ?


Solution

  • The documentation for Pixbuf.save says supported format types include "jpeg" not "jpg":

    pb.save("screenshot.jpg", "jpeg")