Category Archives: Code

Standard XMP data from Corel AfterShot Pro

TL;DR: is a Python script to extract standard XMP data from Corel AfterShot Pro XMP files.

For a few years now I’ve used Corel AfterShot Pro for RAW processing and image management. It’s simple to use, powerful enough for me, has a great image cataloging system and it runs natively on Linux. But support for it has been lagging recently: No updates, no new cameras support, not much public communication from the development team…

Lately I’ve been looking into alternatives, specially open source ones like darktable. But my problem is that I have done a lot of tagging and cataloging, and all that would be lost if I just switched over. AFP does have a function to save a standard XMP file, but that has to be manually triggered for each photo and, even worse, it saves it with a filename that darktable doesn’t recognize, to say nothing of the mess of keeping two XMP files for each image.

So I’ve developed a Python script that can extract standard XMP data from the AFP XMP file and either embed it into the file or put it in a new file. You can get it at, here’s the usage help:

My first WebKit patch landed and I was on vacation!

After doing those 3D demos, I was tasked with porting Rodney Dawes’ work on NPAPI plugins for WebKit/Gtk to QtWebKit. It wasn’t that easy as many plugins assume they’re being loaded by Mozilla, and some depend on Gtk or XPCOM being present. But after a few weeks of work and a lot of help, I finally got Flash working on both ports:

NPAPI plugins on both demo brosers.

The plugin work landed on r32766, while I was on vacation and away from the keyboard, so I just found out this morning reading Marco Barisione’s blog. So a lot of thanks to everyone who helped getting this working: My coworkers at Collabora, Alp Toker and Simon Haussman who reviewed the patch, Rodney Dawes who did the original code and everyone on bug #14750 for a lot of comments, help and support.

There’s still a lot of work to be done, though: Support for windowless plugins, Xt plugins on the Qt port, plugins that ask questions before having created a view like Acrobat Reader… But I think that now that we have the basic support in trunk, other projects will be able to test their NPAPI plugins on WebKit and catch those Mozilla-dependencies bugs.

3D WebKit: Code for the airplane OSG demo

A while ago I published a video showing WebKit rendering as an OpenSceneGraph texture. I’m now publishing the source code in case someone wants to take a look at it: osgGTK and osgWebKit demo.

There are two examples in the code. The first one shows how to implement a GTK+ viewer for OpenSceneGraph using the C++ version of GtkGLExt. The second builds on this to show a modified osgterrain demo with a WebKit-rendered page instead of the terrain texture. To compile this code you’ll need to patch WebKit to support off-screen cairo rendering, you can get the patch at the OpendedHand bugzilla.

As most of the demo code I’ve been publishing lately, it’s more of a proof-of-concept than working code, so handle with care.

Drawing with Cairo on an OpenGL texture

I’ve been looking at the experimental OpenVG backend for Cairo using ShivaVG. One thing I wanted to try was using Cairo to directly generate OpenGL textures without having to use any copying, but this has proven more difficult than I first thought:

  • ShivaVG does not yet support EGL, the platform independent library that the Khronos group pitches to replace GLUT, WGL and other libraries that connect OpenGL to the underlying platform. EGL has support for creating independent framebuffers and rendering to them, while GLUT has no provision for this.
  • ShivaVG initializes itself on a rendering context and uses it all the time, making it difficult to use on different graphics contexts.

Finally, using the framebuffer object extension I’ve been able to make a simple demo of a rotating cube with the famous Cairo Clock as its texture:

OpenGL cube with a Cairo texture.

At first the drawing was completely skewed, until I remembered that OpenGL’s state does not change when the rendering context does. So, for each frame, you have to set up the rendering state to the one ShivaVG needs to draw, and then change it back. It’d be cool if ShivaVG provided functionality to do this, but the code needed to set up the correct rendering environment is not so complex anyway:

	glPushMatrix();  // To keep correct perspective for 3D scene


The demo code is based on an article by Rob “phantom” Jones on GameDev, and it’s a complete hack that should only be used for demo purposes. In fact, it’ll crash and burn a lot if your OpenGL implementation does not support framebufffer objects. You can find the complete code here, cairo_openvg_cube.c.

More 3D WebKit: Now on OpenSceneGraph

This screencast shows an airplane flying over a WebKit-textured terrain. The actual stack used: WebKit to cairo to osgcairo to OpenSceneGraph to a custom GtkViewer on GtkGlExt. Connecting everything together, specially the mouse events, has been a little pain, but the result is pretty:

An airplane flying over WebKit.

The actual resolution and refresh rate are much better than what seems in the screencast, on my lowly laptop it’s perfectly possible to read the page.