singapore: the smallest big galery
home » forum » Mods » Exif howto

You are not logged in.

#1 2008-11-01 19:19:17

bluemoon
Member

Exif howto

Hi, if you want exif information under description in modern style singapore(preview: http://bluechat.nazory.cz ), write ../templates/modern/image.tpl.php like that:

<h2><?php echo $sg->image->name(); ?></h2>
    <h4><?php echo $sg->image->byArtistText(); ?></h4>
</div>
<div id="sgContent"> 

    <div class="sgImageWrapper">
        <div class="sgImageBox" style="width: <?php echo $sg->image->width(); ?>px; ">
            <?php echo $sg->image->imageHTML() ?>
            <a class="thumb" style="width: <?php echo $sg->image->width().'px;" href="'.$sg->image->parent->URL().'"><span>'.$sg->translator->_g("image|Thumbnails").'</span></a>'; ?>
            <?php if($sg->image->hasPrev()) {echo '<a class="prev" style="height:'.$sg->image->height().'px;" href="'.$sg->image->prevURL().'"><span style="margin-top:'.floor(($sg->image->height())/2).'px;">'.$sg->translator->_g("image|Previous").'</span></a>'; } ?>
            <?php if($sg->image->hasNext()) {echo '<a class="next" style="height:'.$sg->image->height().'px;" href="'.$sg->image->nextURL().'"><span style="margin-top:'.floor(($sg->image->height())/2).'px;">'.$sg->translator->_g("image|Next").'</span></a>'; } ?>
        </div>
    </div>

    <?php if ($sg->config->show_fullsizeURL == 1) { ?>
        <p class="sgFullsize"><a href="<?php echo $sg->image->realURL(); ?>"><?php echo $sg->translator->_g("image|View Full Size Image"); ?></a> <a href="<?php echo $sg->image->realURL(); ?>" target="_new">[+]</a></p>
    <?php } ?>

    <div class="sgDetailsList">
        <dl>
            <?php foreach($sg->image->detailsArray() as $key => $value): ?>
                <dt><?php echo $key; ?>:</dt><dd><?php echo $value; ?></dd>
            <?php endforeach; ?>
<br><?
$http = "galleries/".$sg->gallery->name()."/".$sg->image->name().".jpg";
$exif = exif_read_data($http, 0, true);
$focal = $exif["EXIF"]["FocalLength"]/10;
echo $exif["IFD0"]["ImageDescription"].": &nbsp;&nbsp;".$focal."mm &nbsp;&nbsp;".$exif["EXIF"]["ExposureTime"]."sec &nbsp;&nbsp;".$exif["COMPUTED"]["ApertureFNumber"]."&nbsp;&nbsp; ISO".$exif["EXIF"]["ISOSpeedRatings"];
?>
        </dl>
    </div>

    <div class="sgPreview">
        <?php echo $sg->previewThumbnails(); ?>
        <p>
            <?php if($sg->image->hasPrev()) echo "‹ ".$sg->image->prevLink()." &nbsp;&nbsp; "; ?>
            <?php echo $sg->image->parentLink(); ?>
            <?php if($sg->image->hasNext()) echo " &nbsp;&nbsp; ".$sg->image->nextLink()." ›"; ?>   
        </p>
    </div>
</div>
<?php echo $sg->imageMap() ?>

Offline

 

#2 2009-09-03 16:53:48

TheGuru
Member

Re: Exif howto

hi,
i have  install your script in singapore but www does not view exif info.
photos have exif descriptions.
i changed read attributes of directory and i dont have any more ideas what to do.

and second thing.
bottom of page was change.
‹ Wstecz    Miniatury    Dalej ›

whitout your script is
Wstecz    Miniatury    Dalej


what to do??

Offline

 

#3 2009-09-03 19:11:18

DC
Administrator

Re: Exif howto

I would think that should work ...


You might try this php test.
Make a test page and add your own path data and see what ya get.

<?php
echo "test1.jpg:<br />\n";
$exif = exif_read_data('tests/test1.jpg', 'IFD0');
echo $exif===false ? "No header data found.<br />\n" : "Image contains headers<br />\n";

$exif = exif_read_data('tests/test2.jpg', 0, true);
echo "test2.jpg:<br />\n";
foreach ($exif as $key => $section) {
    foreach ($section as $name => $val) {
        echo "$key.$name: $val<br />\n";
    }
}
?>


DC


To code or not to code that is the question?

Did my response help you out? Consider donating by buying me a slice, Whats this? Read More!
http://www.clickcraft.net/slice.php

Offline

 

#4 2009-09-03 19:19:46

bluemoon
Member

Re: Exif howto

and problem may be in subgalleries. better $http is
$http = $sg->image->realURL();

Offline

 

#5 2009-09-04 11:39:02

TheGuru
Member

Re: Exif howto

I thank for your answer,

change did not bring in anything

result under address

http://tonerwielkopolski.pl/foto/index. … ewicz1.jpg

Offline

 

#6 2009-09-06 11:05:26

TheGuru
Member

Re: Exif howto

ok. its works....but not in all photos.
why in one photo it work and in other no?? in photos with exif.

Offline

 

#7 2009-09-11 18:01:53

DC
Administrator

Re: Exif howto

Are you saying the test works only on one photo or the SGAL mod is only working on one photo? If the test works but SGAL does not then your not looping throgh the images correctly would be my first guess ...

DC


To code or not to code that is the question?

Did my response help you out? Consider donating by buying me a slice, Whats this? Read More!
http://www.clickcraft.net/slice.php

Offline

 

#8 2009-09-08 09:05:59

TheGuru
Member

Re: Exif howto

> Exif howtoI would think that should work ...

>You might try this php test.
>Make a test page and add your own path data and see what ya >get.

Hi.

my tests :
1 . bad effect
   http://infobot.pl/r/1q6D
   your test
   http://infobot.pl/r/1q6E

2. good efect
   http://infobot.pl/r/1q6F
   your test
   http://infobot.pl/r/1q6G

i don't see any difrent.

Offline

 

#9 2011-01-14 17:13:13

epse
Member

Re: Exif howto

Hey I just testet a bit arround with this... and it didn't work at all...

I think i got a solution for some of us here ^^

just enter instead of: $http = $sg->image->realURL;
this:

$http = urldecode($sg->image->realURL());

this solved my problem and EXIF data is shown smile

Offline

 

#10 2011-01-14 17:46:48

epse
Member

Re: Exif howto

Oh... me again

in

$focal = $exif["EXIF"]["FocalLength"]/10;

I had do change 10 to 100 to get the right focal length.

The thing above is an issue with php exif... or sgal... it doesnt accept an url but $sg->image->realURL() gives back an url... especially if you have spaces in your Foldernames/Filenames. realURL() gives back a browser compatible format php exif doesn't understand.

Perhaps this was clear and easy to solve for others... for me.. an absolutely php noob it was a big step  wink

Update smile

I've Pictures with and without EXIF in my Gallery... So I've written a small if... (Don't know the english word wink ) which reads the focal length...and if it is bigger than 0 it printes the line with the exif information. Is it 0 then it doesn't print the line.

so far...copy and paste:

Code:

    <h2><?php echo $sg->image->name(); ?></h2>
    <h4><?php echo $sg->image->byArtistText(); ?></h4>
</div>
<div id="sgContent">  

    <div class="sgImageWrapper">
        <div class="sgImageBox" style="width: <?php echo $sg->image->width(); ?>px; ">
            <?php echo $sg->image->imageHTML() ?>
            <a class="thumb" style="width: <?php echo $sg->image->width().'px;" href="'.$sg->image->parent->URL().'"><span>'.$sg->translator->_g("image|Thumbnails").'</span></a>'; ?>
            <?php if($sg->image->hasPrev()) {echo '<a class="prev" style="height:'.$sg->image->height().'px;" href="'.$sg->image->prevURL().'"><span style="margin-top:'.floor(($sg->image->height())/2).'px;">'.$sg->translator->_g("image|Previous").'</span></a>'; } ?>
            <?php if($sg->image->hasNext()) {echo '<a class="next" style="height:'.$sg->image->height().'px;" href="'.$sg->image->nextURL().'"><span style="margin-top:'.floor(($sg->image->height())/2).'px;">'.$sg->translator->_g("image|Next").'</span></a>'; } ?>
        </div>
    </div>

    <?php if ($sg->config->show_fullsizeURL == 1) { ?>
        <p class="sgFullsize"><a href="<?php echo $sg->image->realURL(); ?>"><?php echo $sg->translator->_g("image|View Full Size Image"); ?></a> <a href="<?php echo $sg->image->realURL(); ?>" target="_new">[+]</a></p>
    <?php } ?>

    <div class="sgDetailsList">
        <dl>
            <?php foreach($sg->image->detailsArray() as $key => $value): ?>
                <dt><?php echo $key; ?>:</dt><dd><?php echo $value; ?></dd>
            <?php endforeach; ?>
            <br><?
              $http = urldecode($sg->image->realURL()); 
              $exif = exif_read_data($http, 0, true);
              $focal = $exif["EXIF"]["FocalLength"]/100;
              $model = $exif['IFD0']['Model'];
              if ($focal > 0) {
                  echo $model."&nbsp;&nbsp;".$focal."mm &nbsp;&nbsp;".$exif["EXIF"]["ExposureTime"]."sec &nbsp;&nbsp;".$exif["COMPUTED"]["ApertureFNumber"]."&nbsp;&nbsp; ISO".$exif["EXIF"]["ISOSpeedRatings"];
              }
                
            ?>
        </dl>
    </div>

    <div class="sgPreview">
        <?php echo $sg->previewThumbnails(); ?>
        <p>
            <?php if($sg->image->hasPrev()) echo " ".$sg->image->prevLink()." &nbsp;&nbsp; "; ?>
            <?php echo $sg->image->parentLink(); ?>
            <?php if($sg->image->hasNext()) echo " &nbsp;&nbsp; ".$sg->image->nextLink()." "; ?>    
        </p>
    </div>
</div>
<?php echo $sg->imageMap() ?>

Last edited by epse (2011-01-20 13:45:12)

Offline

 

#11 2011-01-20 13:48:30

epse
Member

Re: Exif howto

..and again... i've played with exif variables... and found some really interesting things.

So I extended the file with nearly all exif variables and some functions.

Code:

    <h2><?php echo $sg->image->name(); ?></h2>
    <h4><?php echo $sg->image->byArtistText(); ?></h4>
</div>
<div id="sgContent">  

    <div class="sgImageWrapper">
        <div class="sgImageBox" style="width: <?php echo $sg->image->width(); ?>px; ">
            <?php echo $sg->image->imageHTML() ?>
            <a class="thumb" style="width: <?php echo $sg->image->width().'px;" href="'.$sg->image->parent->URL().'"><span>'.$sg->translator->_g("image|Thumbnails").'</span></a>'; ?>
            <?php if($sg->image->hasPrev()) {echo '<a class="prev" style="height:'.$sg->image->height().'px;" href="'.$sg->image->prevURL().'"><span style="margin-top:'.floor(($sg->image->height())/2).'px;">'.$sg->translator->_g("image|Previous").'</span></a>'; } ?>
            <?php if($sg->image->hasNext()) {echo '<a class="next" style="height:'.$sg->image->height().'px;" href="'.$sg->image->nextURL().'"><span style="margin-top:'.floor(($sg->image->height())/2).'px;">'.$sg->translator->_g("image|Next").'</span></a>'; } ?>
        </div>
    </div>

    <?php if ($sg->config->show_fullsizeURL == 1) { ?>
        <p class="sgFullsize"><a href="<?php echo $sg->image->realURL(); ?>"><?php echo $sg->translator->_g("image|View Full Size Image"); ?></a> <a href="<?php echo $sg->image->realURL(); ?>" target="_new">[+]</a></p>
    <?php } ?>

    <div class="sgDetailsList">
        <dl>
            <?php foreach($sg->image->detailsArray() as $key => $value): ?>
                <dt><?php echo $key; ?>:</dt><dd><?php echo $value; ?></dd>
            <?php endforeach; ?>
            <br><?
              $http = urldecode($sg->image->realURL()); 
              $exif = exif_read_data($http, 0, true);

              $cameraserial               = $exif['MAKERNOTE']['Camera'];
              $compression                = $exif['IFD0']['Compression'];
              $copyright                  = $exif['COMPUTED']['Copyright'];
              $datetime                   = $exif['IFD0']['DateTime'];
              $datetimeoriginal           = $exif['EXIF']['DateTimeOriginal'];
              $distance                   = $exif['EXIF']['SubjectDistanceRange'];
              $exifversion                = $exif['EXIF']['ExifVersion'];
              $exposure                   = $exif['EXIF']['ExposureTime'];
              $exposurebias               = $exif['EXIF']['ExposureBiasValue'];
              $exposureprogram            = $exif['EXIF']['ExposureProgram'];
              $exifimagewidth             = $exif['EXIF']['ExifImageWidth'];
              $exifimagelength            = $exif['EXIF']['ExifImageLength'];
              $exposuremode               = $exif['EXIF']['ExposureMode'];
              $flash                      = $exif['EXIF']['Flash'];
              $fnumber                    = $exif["COMPUTED"]["ApertureFNumber"];
              $focal                      = $exif["EXIF"]["FocalLength"]/100;
              $filedatename               = $exif['FILE']['FileDateTime'];
              $filesize                   = $exif['FILE']['FileSize'];
              $filetype                   = $exif['FILE']['FileType'];
              $height                     = $exif['COMPUTED']['Height'];
              $imagetype                  = $exif['MAKERNOTE']['ImageType'];
              $iso                        = $exif['EXIF']['ISOSpeedRatings'];
              $fstop                      = $exif['COMPUTED']['ApertureFNumber'];
              $imagewidth                 = $exif['IFD0']['ImageWidth'];
              $imagelength                = $exif['IFD0']['ImageLength'];
              $lens                       = $exif['MAKERNOTE']['UndefinedTag:0x0095'];
              $meteringmode               = $exif['EXIF']['MeteringMode'];
              $mimetype                   = $exif['FILE']['MimeType'];
              $model                      = $exif['IFD0']['Model'];
              $orientation                = $exif['IFD0']['Orientation'];
              $ownername                  = $exif['MAKERNOTE']['OwnerName'];
              $resolutionunit             = $exif['IFD0']['ResolutionUnit'];
              $whitebalance               = $exif['EXIF']['WhiteBalance'];
              $width                      = $exif['COMPUTED']['Width'];
              $xresolution                = $exif['IFD0']['XResolution'];
              $yresolution                = $exif['IFD0']['YResolution'];

              $_cfg['exif']['ExposureMode']=array(
                 'Auto Exposure',
                 'Manual Exposure',
                 'Auto bracket');

              $_cfg['exif']['MeteringMode']=array(
                'unknown',
                'Average',
                'CenterWeightedAverage',
                'Spot',
                'MultiSpot',
                'Pattern',
                'Partial');

              $_cfg['exif']['SubjectDistanceRange']=array(
                 'unknown',
                 'Macro',
                 'Close view',
                 'Distant view');

              $_cfg['exif']['ExposureProgram']=array(
                 'Not defined',
                 'Manual',
                 'Normal program',
                 'Aperture priority',
                 'Shutter priority',
                 'Creative program',
                 'Action program',
                 'Portrait mode',
                 'Landscape mode');
              
              if (is_numeric( $exposuremode)) {
                $exposuremode = $_cfg['exif']['MeteringMode'][$exposuremode];
              }
              if (is_numeric( $meteringmode)) {
                $meteringmode = $_cfg['exif']['MeteringMode'][$meteringmode];
              }
              if (is_numeric( $distance)) {
                $distance = $_cfg['exif']['SubjectDistanceRange'][$distance];
              }
              if (is_numeric( $exposureprogram)) {
                $exposureprogram = $_cfg['exif']['ExposureProgram'][$exposureprogram];
              }



              if ($focal > 0) {
                  echo $model."&nbsp;&nbsp;".$focal."mm &nbsp;&nbsp;".$exposure."sec &nbsp;&nbsp;".$fnumber."&nbsp;&nbsp; ISO".$iso."&nbsp;&nbsp; Metering: ".$meteringmode."&nbsp;&nbsp; Date: ".$datetime;
              }
                
            ?>
        </dl>
    </div>

    <div class="sgPreview">
        <?php echo $sg->previewThumbnails(); ?>
        <p>
            <?php if($sg->image->hasPrev()) echo " ".$sg->image->prevLink()." &nbsp;&nbsp; "; ?>
            <?php echo $sg->image->parentLink(); ?>
            <?php if($sg->image->hasNext()) echo " &nbsp;&nbsp; ".$sg->image->nextLink()." "; ?>    
        </p>
    </div>
</div>
<?php echo $sg->imageMap() ?>

Last edited by epse (2011-01-20 13:58:15)

Offline

 

#12 2011-07-03 04:21:38

mikeatx
Member

Re: Exif howto

I made 2 modifications from epse's last post.

First, most of my photos are from a Canon Rebel, which represents focal length in mm. I changed it to /1 to get the correct output.

The last few lines near the bottom were slightly different and caused the left and right arrows to be replaced by a different letter. Here is my image.tpl.php:


    <h2><?php echo $sg->image->name(); ?></h2>
    <h4><?php echo $sg->image->byArtistText(); ?></h4>
</div>
<div id="sgContent"> 

    <div class="sgImageWrapper">
        <div class="sgImageBox" style="width: <?php echo $sg->image->width(); ?>px; ">
            <?php echo $sg->image->imageHTML() ?>
            <a class="thumb" style="width: <?php echo $sg->image->width().'px;" href="'.$sg->image->parent->URL().'"><span>'.$sg->translator->_g("image|Thumbnails").'</span></a>'; ?>
            <?php if($sg->image->hasPrev()) {echo '<a class="prev" style="height:'.$sg->image->height().'px;" href="'.$sg->image->prevURL().'"><span style="margin-top:'.floor(($sg->image->height())/2).'px;">'.$sg->translator->_g("image|Previous").'</span></a>'; } ?>
            <?php if($sg->image->hasNext()) {echo '<a class="next" style="height:'.$sg->image->height().'px;" href="'.$sg->image->nextURL().'"><span style="margin-top:'.floor(($sg->image->height())/2).'px;">'.$sg->translator->_g("image|Next").'</span></a>'; } ?>
        </div>
    </div>

    <?php if ($sg->config->show_fullsizeURL == 1) { ?>
        <p class="sgFullsize"><a href="<?php echo $sg->image->realURL(); ?>"><?php echo $sg->translator->_g("image|View Full Size Image"); ?></a> <a href="<?php echo $sg->image->realURL(); ?>" target="_new">[+]</a></p>
    <?php } ?>

    <div class="sgDetailsList">
        <dl>
            <?php foreach($sg->image->detailsArray() as $key => $value): ?>
                <dt><?php echo $key; ?>:</dt><dd><?php echo $value; ?></dd>
            <?php endforeach; ?>
            <br><?
              $http = urldecode($sg->image->realURL());
              $exif = exif_read_data($http, 0, true);

              $cameraserial               = $exif['MAKERNOTE']['Camera'];
              $compression                = $exif['IFD0']['Compression'];
              $copyright                  = $exif['COMPUTED']['Copyright'];
              $datetime                   = $exif['IFD0']['DateTime'];
              $datetimeoriginal           = $exif['EXIF']['DateTimeOriginal'];
              $distance                   = $exif['EXIF']['SubjectDistanceRange'];
              $exifversion                = $exif['EXIF']['ExifVersion'];
              $exposure                   = $exif['EXIF']['ExposureTime'];
              $exposurebias               = $exif['EXIF']['ExposureBiasValue'];
              $exposureprogram            = $exif['EXIF']['ExposureProgram'];
              $exifimagewidth             = $exif['EXIF']['ExifImageWidth'];
              $exifimagelength            = $exif['EXIF']['ExifImageLength'];
              $exposuremode               = $exif['EXIF']['ExposureMode'];
              $flash                      = $exif['EXIF']['Flash'];
              $fnumber                    = $exif["COMPUTED"]["ApertureFNumber"];
              $focal                      = $exif["EXIF"]["FocalLength"]/1;
              $filedatename               = $exif['FILE']['FileDateTime'];
              $filesize                   = $exif['FILE']['FileSize'];
              $filetype                   = $exif['FILE']['FileType'];
              $height                     = $exif['COMPUTED']['Height'];
              $imagetype                  = $exif['MAKERNOTE']['ImageType'];
              $iso                        = $exif['EXIF']['ISOSpeedRatings'];
              $fstop                      = $exif['COMPUTED']['ApertureFNumber'];
              $imagewidth                 = $exif['IFD0']['ImageWidth'];
              $imagelength                = $exif['IFD0']['ImageLength'];
              $lens                       = $exif['MAKERNOTE']['UndefinedTag:0x0095'];
              $meteringmode               = $exif['EXIF']['MeteringMode'];
              $mimetype                   = $exif['FILE']['MimeType'];
              $model                      = $exif['IFD0']['Model'];
              $orientation                = $exif['IFD0']['Orientation'];
              $ownername                  = $exif['MAKERNOTE']['OwnerName'];
              $resolutionunit             = $exif['IFD0']['ResolutionUnit'];
              $whitebalance               = $exif['EXIF']['WhiteBalance'];
              $width                      = $exif['COMPUTED']['Width'];
              $xresolution                = $exif['IFD0']['XResolution'];
              $yresolution                = $exif['IFD0']['YResolution'];

              $_cfg['exif']['ExposureMode']=array(
                 'Auto Exposure',
                 'Manual Exposure',
                 'Auto bracket');

              $_cfg['exif']['MeteringMode']=array(
                'unknown',
                'Average',
                'CenterWeightedAverage',
                'Spot',
                'MultiSpot',
                'Pattern',
                'Partial');

              $_cfg['exif']['SubjectDistanceRange']=array(
                 'unknown',
                 'Macro',
                 'Close view',
                 'Distant view');

              $_cfg['exif']['ExposureProgram']=array(
                 'Not defined',
                 'Manual',
                 'Normal program',
                 'Aperture priority',
                 'Shutter priority',
                 'Creative program',
                 'Action program',
                 'Portrait mode',
                 'Landscape mode');
             
              if (is_numeric( $exposuremode)) {
                $exposuremode = $_cfg['exif']['MeteringMode'][$exposuremode];
              }
              if (is_numeric( $meteringmode)) {
                $meteringmode = $_cfg['exif']['MeteringMode'][$meteringmode];
              }
              if (is_numeric( $distance)) {
                $distance = $_cfg['exif']['SubjectDistanceRange'][$distance];
              }
              if (is_numeric( $exposureprogram)) {
                $exposureprogram = $_cfg['exif']['ExposureProgram'][$exposureprogram];
              }



              if ($focal > 0) {
                  echo $model."&nbsp;&nbsp;".$focal."mm &nbsp;&nbsp;".$exposure."sec &nbsp;&nbsp;".$fnumber."&nbsp;&nbsp; ISO".$iso."&nbsp;&nbsp; Metering: ".$meteringmode."&nbsp;&nbsp; Date: ".$datetime;
              }
               
            ?>
        </dl>
    </div>

        <div class="sgPreview">
                <?php echo $sg->previewThumbnails(); ?>
                <p>
                        <?php if($sg->image->hasPrev()) echo "‹ ".$sg->image->prevLink()." &nbsp;&nbsp; "; ?>
                        <?php echo $sg->image->parentLink(); ?>
                        <?php if($sg->image->hasNext()) echo " &nbsp;&nbsp; ".$sg->image->nextLink()." ›"; ?>
                </p>
        </div>
</div>
<?php echo $sg->imageMap() ?>

Offline

 

#13 2011-07-03 04:25:38

mikeatx
Member

Re: Exif howto

Here's an example:

http://mhaertel.com/index.php?gallery=2 … 135820.jpg

This link may break later

Offline

 

#14 2013-01-30 09:37:52

tentionfree
Member

Re: Exif howto

I thank for your answer,


uSMAN geEEE...

Offline