type-conversionpngmetadatatxt

How to add data to a png converted to txt, with the png still being openable?


Maybe it's dumb, but I want to put some text in my .png file so that when you convert it to .txt (by changing its extension) you can read the text.

I have no idea how do this but i tried simply putting the the text before the "%png". On opening the .png paint 3D said there was an error.


Solution

  • You can put a block of text in a PNG file, but it will be surrounded by unreadable data, which will appear to be garbage when displayed as text.

    The PNG format has a tEXt chunk that you can insert in a PNG file, between any other chunks, but after the IHDR chunk. The data in the chunk is a keyword, e.g. Comment followed by a zero byte, and then whatever text you like.