Search code examples
imageperlgdkpixbuf

How can I convert GOPixbuf strings to images


I have an XML file produced with Gnumeric that contains images, stored as GOPixbuf strings inside XML. They look like this:

eXyA/4KEiP9xcnf/f3+E/3l5ff9xb3L/jo2Q/29wdP+ [truncated]

For each string I have width and height, and a rowstride parameter, like in this example:

<GOImage name="Image(70)" type="GOPixbuf" width="151" height="135" rowstride="604">

Is there a reasonable way to convert that to an image - any format will do?

I'm conversant with perl and image conversion tools (imagemagick, gimp) but I have not found any documentation by googling beyond GTK or GOffice docs.


Solution

  • You have already found stuff that is helpful. But since there are no Perl bindings for this on CPAN, you would have to make your own if you want to use Perl.

    Fortunately, you don't have to know XS to do that. You can use FFI::Platypus to create temporary bindings and only map what you need.

    The docs you have probably already found have a Getting started with GOffice section. After a quick check I found that on my recent Ubuntu there is a package that contains that lib. It is called libgoffice-0.10-dev.

    Now you can set that up and play around with the lib functions. Somewhere in https://developer.gnome.org/goffice/unstable/GOImage.html there probably is a method to read and convert it.

    One of the good ones might be go-image-get-pixbuf, which returns a GdkPixbuf. That in turn has a very extensive documentation. Maybe what you need might be in this one.

    Good luck.