function getExif($file) {
global $gallery;
$return = array();
$path = $gallery->app->use_exif;
list($return, $status) = exec_internal(fs_import_filename($path, 1) .
" " .
fs_import_filename($file, 1));
$myExif = array();
if ($status == 0) {
while (list($key,$value) = each ($return)) {
if (trim($value)) {
$explodeReturn = explode(':', $value, 2);
if (isset($myExif[trim($explodeReturn[0])])) {
$myExif[trim($explodeReturn[0])] .= "<br>" .
trim($explodeReturn[1]);
} else {
$myExif[trim($explodeReturn[0])] =
trim($explodeReturn[1]);
}
}
}
}
return array($status, $myExif);
}
Posts: 14
Nevermind. I figured out how modify util.php to limit the fields that get written to the array and how to control the order.
Posts: 3473
Great.
Don't forget to share your changes so others can use it, too.
Posts: 14
I'll try to document it once I get it tweaked.
Posts: 1301
Great!
Gaile
Posts: 14
After working on this a lot, I've had to do a lot of customizing and even some "hacks" to make it do as I wanted it to do. There is more EXIF info in the EXIF spec than jhead reports normally, so you have to make it run in verbose mode to get the extra data. Then I had to parse the results and make arrays to translate the data (so that instead of "Flash mode: 89" you get "Flash mode: Flash fired, Red-eye reduction mode, Return illumination detected"). I also modified the Capture date/time display to a more friendly format.
I'm happy to contribute, but it's not as simple as a few dozen lines of code. And not being a programmer, this is not easy stuff for me to do. So if enough people really want to know more about this, request it here and I'll try to document it.
Posts: 5
seems no one interest in this hack ?
but i m really want to limit the EXIF data being displayed,
there are over 10 lines displayed when enabled the EXIF fields, it seems too much (some is useless) for a guest viewer !
did Toddler found the solution for this yet ??
I would like to know if anyone can solve this problem
Thx a lots !
Posts: 27300
I too am looking and have not had any luck.
getExif(
if ($do_exif) {
$field="EXIF";
it is starting to get blury at this time of the day. I don't think another beer will fix it though. :D
Toddler Have you found a solution? We don't want to reinvent the wheel.
Dave
Posts: 1
hello everybody. i would have only date/time taken from the EXIF data. is that possible?
thanks
best regards, n
Posts: 43
Hello all,
I just completed the logic for the solution to the problem of how to determine what EXIF fields to display. It requires some understanding of PHP associative array structures, and how Gallery 1.4.4 handles EXIF header information (via jhead).
To implement the solution, a new function called excludeExifFields() is implemented in util.php. The source for this function is as follows:
The value, $myExif, passed in (by reference) is the associative array holding EXIF fields and field values created when a call is made into getExif() in util.php.
Note the reference to jhead, which is the library that Gallery calls into to perform EXIF header extraction. The associative array $exif_exclude_list is derived from this jhead data. Unfortunately, these EXIF fields are hardcoded into the jhead exif.c file, which will require manual updating in the event of a update to EXIF field structures (as proposed in the JEITA EXIF 2.2 specification, released April 2002).
To exclude an EXIF field, set the array value from false to true.
The remaining logic first parses $exif_exclude_list into a list (associative array) of those EXIF fields to exclude. The logic then iterates on the $myExif array, removing (call to unset()) those excluded fields.
To correctly make use of excludeExifFields(), call this function after $myExif is created, but just before Gallery routines display or act upon $myExif.
As an example, in the source fragment below, I implemented the call into excludeExifFields() in util.php, function displayPhotoFields(). Note the #### indicating changes in logic:
best of luck,
rich
Posts: 16
Hello all,
I solved this a completely different way. The gallery script simply runs Jhead and then parses out the lines looking for colons to separate out the columns so that the formatting is clean. I didn't want to hack the PHP code since I would have to do that for every release of Gallery. Instead, I wrote a script (batch file) that runs Jhead in verbose mode and uses SED to remove what I didn't like. Here is the script (called jhead.cmd):
--- cut here ---
echo off
c:\gallerybin\jhead -v "%1" | sed -f "c:\gallerybin\jhead.sed"
--- cut here ---
I keep all of the supporting executables for gallery in gallerybin, so use your own paths. The SED program is where the complexity is:
--- cut here ---
# First select the extra rows we want by making sure they
# are formatted with colons.
s/ImageDescription = /Exif Image Description :/
s/Copyright = /Copyright :/
s/JPEG image is/JPEG image is:/
# Now delete any rows that don't have colons in them
/:/!d
# Now delete some random garbage
/DateTime/d
/File size/!{
/bytes/d
}
# Now clean up the data
s/?"//
s/"//
s/copyright .. 200/copyright \& 200/
# Reformat the date
s%Date/Time.*: \(....\):\(..\):\(..\) \(.*\)%Date/Time:\2/\3/\1 \4%
s%File date.*: \(....\):\(..\):\(..\) \(.*\)%File date:\2/\3/\1 \4%
--- cut here ---
If you don't know SED you might be lost by this but the most important parts are the first and the last. The first changes the name=value format to name:value for certain items that I want to appear in Gallery. The last reformats the dates into a format I like better than the EXIF date format. You can play with commenting out lines to see what happens (just put a "#" in front of any line you don't like).
Of course, if you are running Windows you will need to install some version of SED (I use Cygwin). For most of you *nix guys out there you won't have any problems.
You can see an example of my output here:
http://pics.pingbot.com:8002/gallery/sgartner-nature/Boise_downtown_panorama_1
To get Cygwin: http://www.cygwin.com/
Good luck.
Posts: 6
Does anyone know how to modify the exif data display for the version 1.5???
Posts: 16
Can you be more specific. The method I just outlined works with 1.5.
Posts: 6
how to determine which EXIF data to be displayed on the photo properties pop-up?
Posts: 16
The script takes whatever fields are output by JHEAD (which I assume is all of them) and allows you to add or remove fields from the list. If you send me the JHEAD output for one of your pictures with information about which fields, I can probably adjust the script in a couple of minutes and repost it.
However, before you do that, I would suggest that you get the script, as shown above, working on your site.
Posts: 19
I found another small code solution for this in gallery 1.5.7
I know it's been a while since this thread, but I wanted to include my mod here in case others needed the solution
in util.php, there's a part of the code that actually now includes a section of exif headers to exclude!
on line 591, there is a line:
$unwantedFields = array('File name');
you can add any field to this like:
$unwantedFields = array('File name', 'City', 'Keywords');
and these will not show up.
--
I decided it would be easier to put in the fields I wanted rather than the fields I didn't so I made this modification to util.php. Here's the full function for getExif
I've commented where the mods are...
If you notice, I also modified this to ignore if a particular metadata had already been entered, and then it appends additional exif data with a ", " instead of the "<br>".
I did this to fix the fact that it was only including the first keyword from the keywords field
hope this helps someone