Hi all,
Since there is no 1.5 version of this plugin but I'm running 1.5, I made a separate quick hack to implement somewhat the same ideas.
In db_input.php, which registers a new picture in the database, I added a few lines to extract the caption from EXIF unless caption is provided in the web UI form.
Strangely, I also needed to add an UTF encoding, but it might be only because of my weird EXIF writer software. To be safe, you may want to remove the line with "utf8_encode(...)".
Here's a simple patch for that (for version 1.5.16):
*** db_input.php.orig Sun Jan 29 15:43:59 2012
--- db_input.php Sun Jan 29 15:44:07 2012
***************
*** 24,29 ****
--- 24,33 ----
require('include/mailer.inc.php');
require('include/smilies.inc.php');
+ // PATCH modification: store exif comments
+ require("include/exif.php");
+
+
/*known issue: code was edited to not count URL in comment character count. However
this resulted in the character count not being respected at all.
***************
*** 668,673 ****
--- 672,695 ----
}
// Upload is ok
+
+ // PATCH modification: take caption from EXIF if not input separately in form
+ $picture_path = $CONFIG['fullpath'] . $filepath . $picture_name;
+ // If empty caption in form, take from EXIF
+ if($caption === "") {
+ $exif = read_exif_data_raw($picture_path, true);
+ foreach ($exif as $key => $val) {
+ if($key == 'SubIFD') {
+ $caption = substr($val['UserCommentOld'], 5);
+ }
+ }
+ }
+ // HACK, make sure is in correct charset
+ // (my photos seem to have such comments that they are not input correctly without this encoding)
+ // For me, this seems to detect "UTF-8" even if it's not, so not cheking but blindly encoding all
+ ////// mb_detect_encoding($caption);
+ $caption = utf8_encode($caption);
+
// Create thumbnail and internediate image and add the image into the DB
$result = add_picture($album, $filepath, $picture_name, 0, $title, $caption, $keywords, $user1, $user2, $user3, $user4, $category, $raw_ip, $hdr_ip, $superCage->post->getInt('width'), $superCage->post->getInt('height'));