Write a QImageIOPlugin to show custom metadata in Gwenview

Hi,
I’m writing a QImageIOPlugin to enable Gwenview (and Dolphin) to display certain old-school image files. Is it somehow possible to make it so that Gwenview can display all sorts of meta-data about the file? I tried to put that meta-data as strings into the QImage via image->setText(key, value), but none of those strings are shown anywhere.

Also my QImageIOPlugin has two settings which are currently read from environment variables (for fps of animations and blending of color transitions). It would be cool if that could be in the interface somehow, but I guess that is out of the question.

Sure, metadata extraction is implemented in KFilemetada framework library and rendered/accessed by baloo-widgets.
You probably need to add support for your format to this library for that.

And we have a collection of QImageIOPlugin in Frameworks / KImageFormats · GitLab

So I have to write that as a separate plugin, I see. Guess I have to restructure my code as a library that can be used from multiple plugins. But that also means it will parse the file twice? (Looking at log messages it looks like Gwenview parses the file multiple times already for some reason.)

Yeah, I know. It doesn’t support the file type I’m working on. I thought maybe I’ll submit my plugin to that when I’m finished, if they want it.

The metadata reading does not need to read the whole file, just the x first bytes.
And once the file has been accessed the second access normally is very fast due to linux disk page caching, makes it unnoticeable.

They would accept it depending on how common this format is.
Since you haven’t mentioned the format I don’t know.

It’s old and uncommon nowadays: ILBM (interlaced bitmap). Used on Atari and Amiga. It has many sub-formats, which I can’t decode all yet. I’m working on increasing support, but I don’t have example files for all combinations of features. ImageMagick uses ilbmtoppm to read those files. That supports pretty much everything about that file format, except color palette cycling animations (I guess because ppm doesn’t support that). I support those, and those are the most important to me. Currently wondering why showing those via Gwenview makes my CPU go to 75°C while when showing them in my own SDL based viewer it doesn’t do that.

The file format I’m working on usually has the header chunk at the start, yes, but I saw one file where that wasn’t the case, so you’d have to parse the file until you find the header. But then, those files are in general small and the header is definitely always before the body chunk, which is the largest.

Another question: It is not possible to tell QImage that the pixels aren’t squares, but have a certain aspect? Because some of these old files have pixel aspects of 1:2 or 10:11.

That I have no clew, read QImage doc, or you can convert it.
If you don’t need to edit the format that should be sufficient.

You can read at existing code in kimageformats and elsewhere.
I am guessing you will be using libmtoppm as well.

_ Currently wondering why showing those via Gwenview makes my CPU go to 75°C while when showing them in my own SDL based viewer it doesn’t do that.

Are you testing your QImageIOPlugin ? Else might be baloo indexing faced with a strange formt, but your observation is really unreliable as to what is the cause.