[SOLVED] Module Wanted: Exif in Sidebar

timned88

Joined: 2011-08-31
Posts: 90
Posted: Sun, 2011-11-13 18:51

has someone already created a module that displays exif data (aperture/shutter/iso/camera/lens/date) as a neat block in the sidebar?
i have the exif popup installed but would like to see this info automatically displayed in the sidebar. thanks!

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sun, 2011-11-13 19:35

You could hack (edit) the "about this photo" module: http://codex.gallery2.org/Gallery3:Modules:about_this_photo

If you need help with it, there's a thread for the module: http://gallery.menalto.com/node/100075

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-11-13 19:36

The about this photo module might. If not i bet it could be extended to do so.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Sun, 2011-11-13 20:31

I had to considered that but I am not enough of a programmer to know how to make the calls. If someone could at least provide me with how to do one of the fields I could probably figure it out from there. Please help. An example using the shutter speed should be more than sufficient.

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Mon, 2011-11-14 01:19

It could be so extended. I'm not sure about the calls either, as Bharat wrote this part for me, but in principle it shouldn't be hard. I haven't done it because only other photographers want to know this. I'm mainly interested in showing people information about what's in the image.

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Mon, 2011-11-14 01:36

like i said, i could figure out style and format once i had an example on how to make a call and return the value... i am a hacker/modder but not a programmer.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2011-11-22 02:53

is this how you want it displayed?
http://www.langleycom.com/gallery3/index.php/Test1/IMG_1444
looks to me like the sidebar is not that wide or you can make it one column I guess.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Tue, 2011-11-22 03:16

yes, but i only want to display Camera Model, Aperture, Exposure Time, ISO, Date/Time
i can mess with the CSS to make the colors work to my scheme so if you can help edit it down that last little bit it would be awesome.
THANKS

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Tue, 2011-11-29 13:08

dave, any chance of finishing this off? really looking forward to it!

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2011-11-29 21:19

Im out of town right now and have a very crude way and will be making a module on my return. Should be this weekend.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Wed, 2011-11-30 02:17

awesome! SO looking forward to it.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2011-12-05 03:13

Save the attached replacing the existing file.
exif_sidebar.html.php

You will be able to edit the table with the data you want from the EXIF info.
I'm sure there is a better way to do this but it should be easy to follow so you can edit to your desires.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Mon, 2011-12-05 17:33

works perfectly, dave! exactly what i wanted. THANKS!
here is a sample page... after i styled it a bit to suit.
http://themagicinpixels.com/gallery3/index.php/Magic-Kingdom/Liberty-Square/The-Haunted-Mansion/Haunted-Mansion-New-Cemetery-2011-08/Haunted-Mansion-Cemetery-08-2011-_J0E1214

weirdly, the $Date function returns the make of the camera, in my case "Canon".

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2011-12-05 19:23

Some cameras have different EXIF data so try the $DatenTime setting. you might have to view the data from the EXIF module and add to the list that I built there as there might be more data than I have listed available.
Glad it worked out for you.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Tue, 2011-12-06 03:09

i tried that one but it produces UGLY output. is there a way to stylize the output to more conventional means?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2011-12-06 08:41

I have not seen the UGLY bit but can only assume that the formatting is not right.
Try this:
$new_date = date("F j, Y", strtotime($DatenTime));

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Thu, 2011-12-08 14:31

where would you implement this new piece of code?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-12-09 03:09

I would have to test this before I get too far. Got a image with the UGLY output and what code are you using to get the output.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Fri, 2011-12-09 12:59

here ya go...
ALSO... if its not too much to ask, can you work in the "this photo has been viewed X times" from a bit lower in the sidebar to the exif hack?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-12-11 01:46

Your eyes must be good. I can hardly see that. That and the fact that the image does not have any EXIF data so it is hard to test the image to see what this UGLY output is. I see a date and time, is that UGLY?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Sun, 2011-12-11 04:04

Yes,t the format of the output is ugly. That's what i am trying to fix.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-12-11 05:24

I'm not following you have to be specific.
I need examples of what image has the data and how you are retrieving it, how it is UGLY, and what is needed to make it not UGLY.
So to summarize I need:
an example image with the EXIF data
How you are retrieving it
How it displays
How to would look not UGLY

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Crawler

Joined: 2011-12-11
Posts: 9
Posted: Sun, 2011-12-11 10:06

I have a problem with the template and I think it is because I use German as the default language. I attached my current exif_sidebar.html.php that works just works fine except for the camera model (it is shown as Canon, but should be EOS 20D) and I think this is because I don't have the correct german translation for it's entry and I can't seem to find where those are stored. You can have a look at it here: http://digination.de/index.php/Pflanzenvielfalt/IMG_0003

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Sun, 2011-12-11 18:13
floridave wrote:
I'm not following you have to be specific.
I need examples of what image has the data and how you are retrieving it, how it is UGLY, and what is needed to make it not UGLY.
So to summarize I need:
an example image with the EXIF data
How you are retrieving it
How it displays
How to would look not UGLY

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

the way the timestamp is printed comes out like this: 2010:11:08 22:48:43 i would rather it appear as 11/08/2010. that's what i meant by UGLY.

i have left it active on my site so you can see it in play... http://www.themagicinpixels.com/gallery3/index.php/Epcot/World-Showcase/Norway/Spirit-of-Norway/Spirit-of-Norway-2009-12/Spirit-of-Norway-12-2009-003 for one example.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-12-11 18:19
$Camera_Maker		= multidimensional_search($details, array("caption" => "Modell"));
$Camera_Model		= multidimensional_search($details, array("caption" => "Modell"));

you have the same value from the array for each variable.

The attached should work.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-12-11 18:20
Quote:
2010:11:08 22:48:43 i would rather it appear as 11/08/2010. that's what i meant by UGLY.

OK now I understand
let me work on that

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Sun, 2011-12-11 18:24

is there any way to work the number of times viewed into this mod? that would make it perfect. thanks for all of your help.

 
Crawler

Joined: 2011-12-11
Posts: 9
Posted: Sun, 2011-12-11 19:01

Yes, you are right. But that's not the problem. The problem is, that when I use the English captions, I get Canon displayed for every entry. Only when I translate them into German it seems to work. And I don't now what the correct translation for 'Camera Model' should be. The file attached is the one I sue now, that displays for both, maker and model, the same entry (namely Canon).
The main problem seems to be, that your mod only works with English as the used language. Could you perhaps look into that?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2011-12-12 02:24
Quote:
The problem is, that when I use the English captions, I get Canon displayed for every entry.

I'm no EXIF data expert but I don't think that "Blende" is a EXIF standard:
$Aperture = multidimensional_search($details, array("caption" => "Blende")); is right
Try $Aperture = multidimensional_search($details, array("caption" => "Aperture"));
Then you can use the German work in the table not in the variables extracted from the array.
If that does not work then you are going to have to start a new thread and see if there is any multi-lingual / EXIF experts that can help out.
You can do

<pre>
<?
print_r($details);
?>
</pre>

at the end of the file to see what words are used in the array.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2011-12-12 02:31
Quote:
is there any way to work the number of times viewed into this mod?

<?= $theme->item()->view_count; ?>
Should do the trick.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Mon, 2011-12-12 04:03

that sure did. this little hack project is getting better and better all the time. thanks, dave.

 
Crawler

Joined: 2011-12-11
Posts: 9
Posted: Mon, 2011-12-12 08:31

Thank you a 1000 times. That actually worked. The German captions must be Kamera Hersteller (maker) and Kamera Modell (model). Now everything is displayed perfectly.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2011-12-12 14:48

One thing I did discover is that some image have some EXIF data and some don't. So for example if Data is available in some images and Date/Time might be in others you might get some invalid output to a variable that is not set or it grabs the first variable in the array.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Mon, 2011-12-12 15:38

Dave, once we get the date format squared up, this will be one of your most useful mods yet. Thank you so much!
If you go to any page in my gallery (for instance http://www.themagicinpixels.com/gallery3/index.php/Disneyland-Park/Tomorrowland/Star-Tours/Star-Tours-6-2011/Star-Tours-06-2011-020) you can see how I am implementing your code.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2011-12-13 01:21

Formatting the date from a variable is more of a pain than I expected. Some times I'm like a dog with a bone and dig for a long time , but this is getting frustrating. I'm still digging.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Tue, 2011-12-13 02:59

well, i certainly appreciate your efforts!
if it helps, to get the format i am looking for, i modded the about this photo mod to suit. i have activated it back up on my site so you can see it in play, right under the exif hack.
http://www.themagicinpixels.com/gallery3/index.php/Disneyland-Park/Tomorrowland/Star-Tours/Star-Tours-6-2011/Star-Tours-06-2011-020

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Tue, 2011-12-13 06:59

I was on the road when this started up and not in a position to get involved. I thought the idea was to base the new module on "About this photo", but Dave went in a different direction.

If you look at http://codex.gallery2.org/Gallery3:Modules:about_this_photo you will see that the Date is formatted closer to how you want. The relevant code from the helper file is

      if (module::is_active("exif")) {
        $exif = ORM::factory("exif_record")->where("item_id", "=", $theme->item()->id)->find();
        if ($exif->loaded()) {
          $exif = unserialize($exif->data);
          $timestamp = strtotime($exif["DateTime"]);
	  $block->content->date = date('D j M Y', $timestamp);
          $block->content->time = gallery::time($timestamp);
        }
      }

Formatting the date uses the variables D j M Y in "date('D j M Y', $timestamp)". You can vary the formatting by changing the variables, noting that case is very important.

U-G

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Thu, 2011-12-15 04:31

yes, i have that running on my side in a separate module. how would i combine that with the exif module to make it appear seamless (i.e. where to copy/paste the above code, and how to call it to display the date). thanks!

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Fri, 2011-12-16 23:05

I have to admit that I'm a little confused. When I made my previous post I thought Dave had created a new module. Reading the thread again I'm not so sure. Which module is the file exif_sidebar.html.php that he provided for? Some of the posts seem to imply that people are basing their work on About this photo. I don't mind either way, but I want to understand so that I help and not confuse others.

Also rereading the thread again I see that Dave already gave the sort of advice in http://gallery.menalto.com/node/104245?page=1#comment-384897 that I was trying to provide. The key to getting the date format that you want is to start with a date and time variable and use the PHP date function to format it. In Dave's post he suggested

$new_date = date("F j, Y", strtotime($DatenTime));

So the variable $DatenTime is the combined date and time variable that he retrieves in his exif_sidebar.html.php file. The documentation for the PHP date function is http://php.net/manual/en/function.date.php . You construct the date format you want by replacing "F j, Y" in the above code with the variables you want chosen from the documentation. If you're using Dave's exif_sidebar.html.php I guess you'd need to add a new row which displays the $new_date variable based on the above code.

I hope this helps and doesn't simply add to the confusion.

U-G

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Tue, 2012-01-10 16:45

ok, to clarify, i am using a heavily modified version of the exif module which is doing most of what i want it to do. i originally began messing with the about this photo module but found the exif module, once modded, was truer to my original intention.

i am now trying to find out where to implete your code ($new_date = date("F j, Y", strtotime($DatenTime));) into that module to produce the date/time output that i am looking for.

here is the complete code from exif_sidebar.html.php that i am running on my site:

<style type="text/css">
div.transbox
  {
  background-color:#ffffff;
  border:1px solid black;
  opacity:0.6;
  filter:alpha(opacity=60); /* For IE8 and earlier */
  }
div.transbox p
  {
  margin:30px 40px;
  font-weight:bold;
  color:#000000;
  }
</style>
  
  
<?
$item = $theme->item();
$details = exif::get($item);
function multidimensional_search($parents, $searched) { 
  if (empty($searched) || empty($parents)) { 
    return false; 
  }
  foreach ($parents as $key => $value) { 
    $exists = true; 
    foreach ($searched as $skey => $svalue) { 
      $exists = ($exists && IsSet($parents[$key][$skey]) && $parents[$key][$skey] == $svalue); 
    } 
    if($exists){ return $key; } 
  } 
  
  return false; 
}       
$Aperture 			= multidimensional_search($details, array("caption" => "Aperture"));
$Date				= multidimensional_search($details, array("caption" => "Date"));
$Flash				= multidimensional_search($details, array("caption" => "Flash"));
$Camera_Maker		= multidimensional_search($details, array("caption" => "Camera Maker"));
$Camera_Model		= multidimensional_search($details, array("caption" => "Camera Model"));
$Color_Space		= multidimensional_search($details, array("caption" => "Color Space"));
$Exposure_Value		= multidimensional_search($details, array("caption" => "Exposure Value"));
$Exposure_Program	= multidimensional_search($details, array("caption" => "Exposure Program"));
$Exposure_Time		= multidimensional_search($details, array("caption" => "Exposure Time"));
$Flash				= multidimensional_search($details, array("caption" => "Flash"));
$Focal_Length		= multidimensional_search($details, array("caption" => "Focal Length"));
$ISO				= multidimensional_search($details, array("caption" => "ISO"));
$Metering_Mode		= multidimensional_search($details, array("caption" => "Metering Mode"));
$DatenTime			= multidimensional_search($details, array("caption" => "Date/Time"));
$Copyright			= multidimensional_search($details, array("caption" => "Copyright"));
$Orientation		= multidimensional_search($details, array("caption" => "Orientation"));
$Resolution_Unit	= multidimensional_search($details, array("caption" => "Resolution Unit"));
$X_Resolution		= multidimensional_search($details, array("caption" => "X Resolution"));
$Y_Resolution		= multidimensional_search($details, array("caption" => "Y Resolution"));
$Brightness_Value	= multidimensional_search($details, array("caption" => "Brightness Value"));
$Scene_Type			= multidimensional_search($details, array("caption" => "Scene Type"));
$Subject_Distance	= multidimensional_search($details, array("caption" => "Subject Distance"));        
?>

<div id="g-exif-data" class="g-block">
<h2><?= t("EXIF Data") ?></h2><br />
  <DIV style="border-width:thin; border-style:solid">
  <table class="g-metadata" >
    <tbody>
      <tr>
         <td class="transbox">
         Aperture:
         </td>
         <td class="transbox">
         <?= $details[$Aperture]["value"] ?>
         </td>
	  </tr>
      <tr>
         <td class="transbox">
         Shutter:
         </td>
         <td class="transbox">
         <?= $details[$Exposure_Time]["value"] ?>
         </td>
	  </tr>
      <tr>
         <td class="transbox">
         ISO:
         </td>
         <td class="transbox">
         <?= $details[$ISO]["value"] ?>
         </td>
	  </tr>
      <tr>
         <td class="transbox">
         Camera:
         </td>
         <td class="transbox">
         <?= $details[$Camera_Model]["value"] ?>
         </td>
	  </tr>
	    <tr>
         <td class="transbox">
         TimeStamp:
         </td>
         <td class="transbox">
         <?= $details[$DatenTime]["value"] ?>
         </td>
	    </tr>
	    	 <tr>
	    	 <td>
	    	   <DIV style="border-width:thin; border-style:solid">
         <center> This photo has been viewed <font size="2"><b><?= $theme->item()->view_count+1; ?></b></font> times.</center></div>
      </td></tr>

    </tbody>
  </table>
 
</div>
</div>

the problem i am having is the $FDatentime variable produces output that looks like this - TimeStamp: 2011:06:18 19:56:10

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2012-01-13 05:41

I forgot that the EXIF data is serialaized.
My way is way to much code for what you are after. If I get time I might create a new module for EXIF in the sidebar similar to waht you have.

Either way this should get you the proper date:

<?
$exif = ORM::factory("exif_record")->where("item_id", "=", $theme->item()->id)->find();
$exif = unserialize($exif->data); 
$timestamp = strtotime($exif["DateTime"]);
$formatedDate = date('F j, Y', $timestamp);
?>
<?= $formatedDate ?>

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Fri, 2012-01-13 12:26

Thanks, Dave. Where does this code go? I will try to implement it right away.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2012-01-13 16:20

Just replace
<?= $details[$DatenTime]["value"] ?>

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
timned88

Joined: 2011-08-31
Posts: 90
Posted: Fri, 2012-01-13 16:39

shot.... SCORE! thanks, dave!

 
smokers

Joined: 2012-06-02
Posts: 1
Posted: Sat, 2012-06-02 20:53

here my shorten version ;-)

Quote:
<style type="text/css">
#g-exif-data { font-size: 8pt; }
.g-odd { background: #1e1e1e; }
.g-even { background: transparent; }
</style>
<?
$item = $theme->item();
$details = exif::get($item);

?>

<div id="g-exif-data" class="g-block">
<h2><?= t("EXIF Daten") ?></h2>
<table class="g-metadata" >
<tbody>
<?php
foreach ($details as &$element) {
?>
<tr>
<td class="g-even">
<strong><?php echo $element["caption"]; ?></strong>
</td>
<td class="g-even">
<?php echo $element["value"]; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>

Its just output, no formating and else

 
Crawler

Joined: 2011-12-11
Posts: 9
Posted: Sun, 2012-07-01 20:26

I have a question that is not directly (or only) linked to exif_sidebar.php. I got everything working as I want it to (see http://digination.de/index.php/Nikon-D90-Impressionen/DSC_0831) My problem now is, that I want to re-arrange the sidebar-items, but in the admin panel I can't move the EXIF-information because it doesn't show up. All the other entries (album tree, social links, picture download) can be arranged via the admin panel. Can anyone tell me how to get the EXIF information to the top of the sidebar?

 
Crawler

Joined: 2011-12-11
Posts: 9
Posted: Mon, 2012-07-02 19:16

I just found out, that when I change line 21 in /modules/exif/helpers/exif_theme.php from 'static function sidebar_bottom' to 'static function sidebar_top' the EXIF-box moves to the top of the sidebar. How could I use this to put it on the second position?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2012-07-06 02:50