7

is there a way to add some extra metadata to a PNG file and then retrieve it with PHP ?

like Comment field.

Todd
  • 5,999
  • 2
  • 21
  • 21
  • Are you talking about image metadata, such as a comment field? `stat` doesn't have anything to do with that, or PNG files: `stat` gets information on the file, such as size, times, etc. – Thanatos Dec 21 '10 at 07:55
  • @Thanatos: yes like comment field and how to add extra fields, I know stat only output the file size and some other information i was thinking if some how to add some extra data to it. –  Dec 21 '10 at 07:56
  • 1
    The answers to this question might be helpful to you. http://stackoverflow.com/questions/2190236/how-can-i-read-png-metadata-from-php –  Dec 21 '10 at 07:59
  • some program like [exiftool](http://www.sno.phy.queensu.ca/~phil/exiftool/) ? – ajreal Dec 21 '10 at 08:08
  • [Here](https://github.com/lsolesen/pel/) is a handy php exif manipulation library. – cbrandolino Dec 21 '10 at 08:40
  • Possible duplicate of [How can I add metadata to an image?](https://stackoverflow.com/questions/3462236/how-can-i-add-metadata-to-an-image) – tres.14159 Jun 12 '19 at 08:37

1 Answers1

8

If you have ImageMagick installed, it comes with two utilities: mogrify and identify.

To add comments:

$ mogrify.exe -comment "My test comment" plogo.png

To retrieve comments:

$ identify.exe -verbose plogo.png  | grep -i "comment:"
    comment: My test comment

I don't know if mogrify/identify functions are available as PHP libraries, but you can always use the php system command.

  • thanks for you answer but i think Imagmagic is a bit expansive for the what I wanna do. –  Dec 22 '10 at 06:12