1

My goal is simple: I'd like to modify the 'Comments' field on an image. This is easy to do manually on any file on Windows (just right click and type in whatever you want).

To do so via PHP does not seem clear at all. There are several drivers out there. I have tried them all and simply could not get them to work. Does anyone have direct experience with one and can provide a concrete example how to do this?

The only thing I got that sort of worked was this http://blog.jacobemerick.com/web-development/manipulating-jpeg-exif-headers/.

However, although I can update some fields it also deletes everything else. I have no experience with EXIF before and from what I can tell he is decodeing the raw image data and interpreting the sections. I simply do not have the knowledge to modify his code for my purposes.

I've tried https://github.com/romainneutron/PHPExiftool but I simply get errors about different classes not being available. I guess this is expected as it's clearly still in development.

I would appreciate any guidance as I'm pretty sure I've read everything the internet has to offer on the topic.

user2029890
  • 2,493
  • 6
  • 34
  • 65
  • Have you looked at iptcembed()? http://www.php.net/manual/en/function.iptcembed.php Lots of hints (older) in the comments. – AllInOne Jul 02 '14 at 22:14
  • I have not - but will try. Can it edit any of the EXIF info or just those designated as IPTC? (apparently EXIF is data captured at image creation and IPTC can be added later). – user2029890 Jul 02 '14 at 23:10
  • Appears that it's IPTC only. See http://stackoverflow.com/a/10010663/955002 and http://lsolesen.github.io/pel/ for alternatives. – AllInOne Jul 03 '14 at 15:49
  • Hi, did you found a solution. jacobemerick's solution well but as you mention there are some problems. – Deniz Porsuk Sep 18 '14 at 09:51

1 Answers1

1

The easiest way is to just use exiftool via imagemagick. This is technically command line, not PHP, though you can use exec (bad) or lean on some of PHP's imagemagick extension. The post you linked to was something I wrote a few years ago and has a few limitations... Only working for certain encoding (Canon, can't remember the specifics) and yes, it does strip out everything and then rebuild. Easier than surgical replacements ;)