Apart from the link to the script I gave in the comments, it depends on where you need the data. If you want to view it directly in Blender to adjust settings according to the metadata of a different, it is probably easiest to just open the image in Blender.
First of all, here under Output Properties > Metadata is where you can find some predefined data which can be stored in the image by checking it (and in your previously saved images the data which is checked by default should already be stored), if the existing things are not enough you can also check Note to enter a custom text you want to save as well. By the way, although you cannot check them in the Metadata section, the number of samples for Cycles renders is automatically stored as well, also the render times per view layer if you render more than one (even if they do not wind up in the final composite).
If you open the file in a text editor, in case of a PNG file the metadata all have a "tEXt" in front of them, here a cropped view of a header:
But of course this is very messy and not so easy to read. But as I said, if you need it mostly in Blender, there you can easily retrieve data by just opening an image in the Image Editor for example, there you can find them in the Image tab of the sidepanel: