Store and retreive string in PNG (Issue #25556)

41 views
Skip to first unread message

GenevensiS

unread,
Jun 23, 2025, 6:58:17 AM6/23/25
to wx-...@googlegroups.com, Subscribed
G-e-n-e-v-e-n-s-i-S created an issue (wxWidgets/wxWidgets#25556)

Is it possible to store some string data inside a wxImage, save it to disk as a PNG image, then later load it and retrieve the string?

I tried using wxImage::SetOption() and wxImage::GetOption() but these don't seem to persist upon writing to disk.

I also haven't found any function to access the iTXt, tEXt, or zTXt chunks.

I'm open to any kind of ugly/platform specific hack (except storing it in the filename).

Thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25556@github.com>

Igor Korot

unread,
Jun 23, 2025, 7:57:47 AM6/23/25
to wx-dev, Subscribed
Hi,


On Mon, Jun 23, 2025, 6:58 AM GenevensiS <git...@wxwidgets.org> wrote:
G-e-n-e-v-e-n-s-i-S created an issue (wxWidgets/wxWidgets#25556)

Is it possible to store some string data inside a wxImage, save it to disk as a PNG image, then later load it and retrieve the string?

I tried using wxImage::SetOption() and wxImage::GetOption() but these don't seem to persist upon writing to disk.


What do you mean?
Is the file not there?
Or it doesn't contain the proper data?


I also haven't found any function to access the iTXt, tEXt, or zTXt chunks.


That should be PNG functionality. Check it's documentation to find out how...

I'm open to any kind of ugly/platform specific hack (except storing it in the filename).


Thank you.

Thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25556@github.com>

--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wx-dev/wxWidgets/wxWidgets/issues/25556%40github.com.

VZ

unread,
Jun 23, 2025, 9:55:06 AM6/23/25
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25556)

No, wxImage doesn't provide support for working with PNG-specific chunks. In principle, it should be possible to handle this using the existing options mechanism by defining more PNG-specific options corresponding to such chunks, but it risks being really ugly. If you need full support of the PNG format, using libpng directly is probably a better idea.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25556/2996599759@github.com>

GenevensiS

unread,
Jun 23, 2025, 11:35:42 PM6/23/25
to wx-...@googlegroups.com, Subscribed
G-e-n-e-v-e-n-s-i-S left a comment (wxWidgets/wxWidgets#25556)

I don't need full PNG support. I really just need the bare minimum functionality of storing a string inside the file when saving it on disk, and retrieving it on load.

I'm trying to avoid adding yet another library dependency to my project just for a single function. You're saying it can be done with Options in principle? Would I need to override the wxImage::SaveFile() function? I'm willing to give it a go if you can start me in the right direction.

Thanks for your reply.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25556/2998682161@github.com>

VZ

unread,
Jun 24, 2025, 11:05:42 AM6/24/25
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25556)

You already have an implicit dependency on libpng, as it's used by wxImage, so using it shouldn't be a big change.

Anyhow, you can't do this outside of wx. What I meant by "it can be done with options in principle" is that it should be relatively simple to add some wxIMAGE_OPTION_PNG_tEXt and handle it in the code by loading it from/saving it to tEXt chunk. This still needs to actually be done.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25556/3000870980@github.com>

GenevensiS

unread,
Jun 28, 2025, 8:06:12 PM6/28/25
to wx-...@googlegroups.com, Subscribed

Closed #25556 as completed.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/25556/issue_event/18371860190@github.com>

GenevensiS

unread,
Jun 28, 2025, 8:06:14 PM6/28/25
to wx-...@googlegroups.com, Subscribed
G-e-n-e-v-e-n-s-i-S left a comment (wxWidgets/wxWidgets#25556)

Solved by #25565


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25556/3016171732@github.com>

Reply all
Reply to author
Forward
0 new messages