Accessing the PNG metadata

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Accessing the PNG metadata

Post by Widgets »

Since wxWidgets uses libpng, I was looking for a way to access the PNG chunks in order to read the metadata, but I have not been able to figure out how I can access these functions in libpng after loading a PNG image the usual wxWidgets wxPNGHandler:LoadFile() or, FWIW, any other way without having to add my own PNG code.
I am not showing any code, because I really don't have anything that comes anywhere near working.
TIA
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Accessing the PNG metadata

Post by doublemax »

Some data may be accessible through image options:
https://docs.wxwidgets.org/trunk/classw ... 1615e05de4

To access Exif data you'll need an additional library, e.g.
https://github.com/mayanklahiri/easyexif
Use the source, Luke!
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Accessing the PNG metadata

Post by Widgets »

At least I did not miss anything very obvious :-)
From what I can tell, there is no option to help me get what I need.

Unfortunately, easyexif seems to only be usable with JPG.
The original PNG spec never contained any EXIF data a la JPG and many utilities do not recognize it. The current spec does include such a chunk, and I do want to be able to at least list the chunks found/present and if possible or wanted/needed interpret and show the data for each.

Fortunately, your suggestion for 'option' had ne look at the source more carefully and it might be possible to get access to the raw data with
image->GetData().
That will be my next target.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Accessing the PNG metadata

Post by Widgets »

It looks like GetData() will NOT help me since it only gets the image data :cry: and all the rest is hidden.
Likely will have to load another copy of libpng and whatever support it will need - such as png++
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Accessing the PNG metadata

Post by doublemax »

Which meta data are you looking for?
Use the source, Luke!
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Accessing the PNG metadata

Post by Widgets »

Pretty well all metadata, specially for PNG images. There are good, or better, libraries for JPG at least.
What got me started on this quest is my interest in both genealogy and metadata. Gramps does have some built-in and optional facilities to display metadata for media which are part of its database. But this specific issue came to the fore when I realized that Gramps only displays metadata for JPGs, and not for PNG images. Whether other image types - TIFF, PDF etc - are handled, I have not yet confirmed one way or the other.
And as it turns out, very few utilities handle or support the rather recent Exif data in PNG images. Seemingly all depend on libpng and are tied to the same limitations

For my needs, as a minimum I need would be to at least identify which chunks exist within an image file. Most would be of no interest for my work, but some very definitely would, specifically the EXIF chunk.
At present, Tweakpng is the only utility I have found for displaying most chunks, but even it does not handle EXIF data well. It identifies the EXIF chunk but marks it as 'unrecognized'.
Since both Tweakpng & wxWidgets are based on libpng, I was hoping the the built-in support within wxWidgets might be usable. But the wxWidgets interface does not handle that part of the image at all. And neither does the C++ wrapper pngpp/png++.
All of these have limited themselves to manipulating image data.

Unfortunately libpng is old enough and is written in plain C code, using setjmp/longjmp to handle exceptions. wxWidgets seems to be able to work around that peculiarity.

Right now, it almost looks like the only way forward for this need is to rework something like libpng from the ground up and that would likely use up too many scarce resources for anything but some sort of ad hoc work around

Currently, I am investigating lodepng
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Accessing the PNG metadata

Post by ONEEYEMAN »

Hi,
Why do you need to access it? What specific info you are looking for to find?
Can you explain your need /scenario in plain English?

Usually all you need to do is to display the image somewhere...

Thank you.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Accessing the PNG metadata

Post by Widgets »

Simply because I want/need to access the metadata, or, in some cases need/want to know whether the file contains any or a specific metadata item or not!
This, for my need, applies to JPG, PNG, TIFF and possibly PDF files.
The image information is only part of the 'picture', if you pardon the pun :-)
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Post Reply