Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 03-02-2005, 09:50 PM
Connie
Guest
 
Posts: n/a
Mod for EXIF / copied from other not adequate posting

this message was added by the user "commando"
sorry, I had to copy this posting and place it here :cry:
===================


Quote:
Originally Posted by bretzelman
Is there a markup for Iso speed?
ISO Speed is not in there, but it is easy to add. The following are my changes to the EXIF section of index.php. Notice that I don't like the extra text added to my tags, I prefer to do that in my template. Also, for some reason, my camera prints the focal length as 800/10, so I convert it. I have also added the 35mm equivilent focal length so that I can compare between cameras... Enjoy 8)

Code:
// EXIF STUFF
if(extension_loaded(exif)) {
        $curr_image = "images/$image_name";
        $all_exif = exif_read_data($curr_image,0,true);
        $exif = $all_exif['EXIF'];
        //echo "<pre>"; print_r($all_exif); echo "</pre>";
        $exposure = $exif['ExposureTime'];
        $exifhtml = $all_exif['COMPUTED'];
        $aperture = pullout($exifhtml['ApertureFNumber']);
        $capture_date = $exif['DateTimeOriginal'];
        $flash = $exif['Flash'];
        $lens = pullout($exif['LensModel']);
        $focal = pullout($exif['FocalLength']);
        $pos = strpos( $focal, "/" );
        if( $pos ) {
                list($e, $d) = sscanf($focal, "%d/%d");
                $focal = sprintf( "%d", intval($e/$d) );
        }
        $iso = pullout($exif['ISOSpeedRatings']);
        $focal35mm = pullout($exif['FocalLengthIn35mmFilm']);
        $ifd = $all_exif['IFD0'];
        $info_camera_manu = $ifd['Make'];
        $info_camera_model = $ifd['Model'];
        if($flash == 0) {
                $flash = "$lang_flash_not_fired";
                } else {
                $flash = "$lang_flash_fired";
                }
    if($iso != "") { $iso = "ISO $iso"; }
    //if($exposure != "") { $exposure = "$lang_exposure $exposure"; }
    //if($aperture != "") { $aperture = "$lang_aperture $aperture"; }
    //if($capture_date != "") { $capture_date = "$lang_capture_date $capture_date"; }
    //if($focal != "") { $focal = "$lang_focal $focal"; }
    //if($info_camera_manu != "") { $info_camera_manu = "$lang_camera_maker $info_camera_manu"; }
    //if($info_camera_model != "") { $info_camera_model = "$lang_camera_model $info_camera_model"; }
    $tpl = ereg_replace("<EXIF_EXPOSURE_TIME>",$exposure,$tpl);
    $tpl = ereg_replace("<EXIF_APERTURE>",$aperture,$tpl);
    $tpl = ereg_replace("<EXIF_CAPTURE_DATE>",$capture_date,$tpl);
    $tpl = ereg_replace("<EXIF_FLASH>",$flash,$tpl);
    $tpl = ereg_replace("<EXIF_FOCAL_LENGTH>",$focal,$tpl);
    $tpl = ereg_replace("<EXIF_35MM_FOCAL_LENGTH>",$focal35mm,$tpl);
    $tpl = ereg_replace("<EXIF_CAMERA_MAKE>",$info_camera_manu,$tpl);
    $tpl = ereg_replace("<EXIF_CAMERA_MODEL>",$info_camera_model,$tpl);
    $tpl = ereg_replace("<EXIF_LENS>",$lens,$tpl);
    $tpl = ereg_replace("<EXIF_ISO>",$iso,$tpl);
    }
Reply With Quote
  #2  
Old 03-03-2005, 05:58 AM
Connie
Guest
 
Posts: n/a
moved from other topic to here

Quote:
Originally Posted by GregWilker
okay am i missing something with this code. do i need to change anything in any other folder cause when i uploaded it my modded index.php file with your code added i get a blank white page with nothing showing.

Code:
// EXIF STUFF
if(extension_loaded(exif)) {
        $curr_image = "images/$image_name";
        $all_exif = exif_read_data($curr_image,0,true);
        $exif = $all_exif['EXIF'];
        //echo "<pre>"; print_r($all_exif); echo "</pre>";
        $exposure = $exif['ExposureTime'];
        $exifhtml = $all_exif['COMPUTED'];
        $aperture = pullout($exifhtml['ApertureFNumber']);
        $capture_date = $exif['DateTimeOriginal'];
        $flash = $exif['Flash'];
        $lens = pullout($exif['LensModel']);
        $focal = pullout($exif['FocalLength']);
        $pos = strpos( $focal, "/" );
        if( $pos ) {
                list($e, $d) = sscanf($focal, "%d/%d");
                $focal = sprintf( "%d", intval($e/$d) );
        }
        $iso = pullout($exif['ISOSpeedRatings']);
        $focal35mm = pullout($exif['FocalLengthIn35mmFilm']);
        $ifd = $all_exif['IFD0'];
        $info_camera_manu = $ifd['Make'];
        $info_camera_model = $ifd['Model'];
        if($flash == 0) {
                $flash = "$lang_flash_not_fired";
                } else {
                $flash = "$lang_flash_fired";
                }
    if($iso != "") { $iso = "ISO $iso"; }
    //if($exposure != "") { $exposure = "$lang_exposure $exposure"; }
    //if($aperture != "") { $aperture = "$lang_aperture $aperture"; }
    //if($capture_date != "") { $capture_date = "$lang_capture_date $capture_date"; }
    //if($focal != "") { $focal = "$lang_focal $focal"; }
    //if($info_camera_manu != "") { $info_camera_manu = "$lang_camera_maker $info_camera_manu"; }
    //if($info_camera_model != "") { $info_camera_model = "$lang_camera_model $info_camera_model"; }
    $tpl = ereg_replace("<EXIF_EXPOSURE_TIME>",$exposure,$tpl);
    $tpl = ereg_replace("<EXIF_APERTURE>",$aperture,$tpl);
    $tpl = ereg_replace("<EXIF_CAPTURE_DATE>",$capture_date,$tpl);
    $tpl = ereg_replace("<EXIF_FLASH>",$flash,$tpl);
    $tpl = ereg_replace("<EXIF_FOCAL_LENGTH>",$focal,$tpl);
    $tpl = ereg_replace("<EXIF_35MM_FOCAL_LENGTH>",$focal35mm,$tpl);
    $tpl = ereg_replace("<EXIF_CAMERA_MAKE>",$info_camera_manu,$tpl);
    $tpl = ereg_replace("<EXIF_CAMERA_MODEL>",$info_camera_model,$tpl);
    $tpl = ereg_replace("<EXIF_LENS>",$lens,$tpl);
    $tpl = ereg_replace("<EXIF_ISO>",$iso,$tpl);
    }
[/quote]
Reply With Quote
  #3  
Old 03-04-2005, 06:10 PM
Rob Offline
pixelpost guru
 
Join Date: Mar 2005
Location: Burlington, Canada
Posts: 342
Send a message via ICQ to Rob Send a message via MSN to Rob
Some of the lines in the post have been word wrapped by the board. Make sure that you join all of the lines that are not indented back to the previous line in your code. It is probably those lines with just the } on them that are causing the most problem since they should be commented out in the previous line... :wink:

The next thing you will want to do is add the new tags to your template.

<EXIF_35MM_FOCAL_LENGTH> // This only works with my SLR, not my Olympus, give it a try
<EXIF_ISO> // Should be supported by most cameras

Also, don't forget that I removed the extra text from most of the EXIF tags, so you will need to add that to the template if you want it. I didn't want text like "Aperature:" forced on me.

Hope this helps. Check out my website to see it in action. Reply to this if not, I am watching this topic now...
__________________
shifted*exposure powered by PixelPost 1.4
Reply With Quote
  #4  
Old 03-05-2005, 04:13 AM
GregWilkerPhoto Offline
forum loafer
 
Join Date: Dec 2004
Posts: 18
not sure what im doing wrong here everytime i edit it even when i make sure it should look the way you had it with out word warp - it still gives me a blank page... =\
__________________
my pixelpost photoblog
Reply With Quote
  #5  
Old 03-07-2005, 08:05 PM
Rob Offline
pixelpost guru
 
Join Date: Mar 2005
Location: Burlington, Canada
Posts: 342
Send a message via ICQ to Rob Send a message via MSN to Rob
Email your edited index.php to me at rob at prouse.org and I will take a look at it for you, fix it and send it back.
__________________
shifted*exposure powered by PixelPost 1.4
Reply With Quote
  #6  
Old 03-07-2005, 08:53 PM
raminia's Avatar
raminia+ Offline
Team Pixelpost
 
Join Date: Jan 2005
Location: FL, US
Posts: 3,706
Send a message via Yahoo to raminia
@Commando
Nice Avatar!
__________________
Photoblog: http://pblog.raminia.com Powered by Pixelpost 1.7
Reply With Quote
  #7  
Old 03-09-2005, 12:49 AM
marlyse's Avatar
marlyse Offline
pp regular
 
Join Date: Mar 2005
Location: USA
Posts: 31
Send a message via AIM to marlyse Send a message via MSN to marlyse Send a message via Skype™ to marlyse
Quote:
Originally Posted by GregWilkerPhoto
not sure what im doing wrong here everytime i edit it even when i make sure it should look the way you had it with out word warp - it still gives me a blank page... =\
Blank pages is faulty PHP code - in this case because you copy/paste the code from an HTML page.

If you replace the empty spaces at each code line in the beginning with a TAB (4 empty spaces = 1 TAB), then you should be fine.

You need to do that in a word processor where you can see the hidden stuff like returns and spaces, you then will notice that they look different than standard text input.
Reply With Quote
  #8  
Old 03-10-2005, 07:06 AM
n0d3 Offline
forum loafer
 
Join Date: Feb 2005
Location: localhost
Posts: 17
Send a message via ICQ to n0d3 Send a message via MSN to n0d3
Is there anyway to format the way the date/time turns out?
Reply With Quote
  #9  
Old 03-10-2005, 08:33 AM
Connie
Guest
 
Posts: n/a
did you try the date-format-option in the admin panel ?
Reply With Quote
  #10  
Old 03-10-2005, 01:40 PM
Rob Offline
pixelpost guru
 
Join Date: Mar 2005
Location: Burlington, Canada
Posts: 342
Send a message via ICQ to Rob Send a message via MSN to Rob
Quote:
Originally Posted by Connie
did you try the date-format-option in the admin panel ?
I think he means the EXIF_CAPTURE_DATE. The control panel will not change that, it is currently just read and displayed from the photo. To get the date formatted by the control panel, change the one line of code in my code above (or in the original index.php) to the following three lines (the first line remains the same and is just so you know where to put it.)

Code:
$capture_date = $exif['DateTimeOriginal'];
$capture_date = strtotime($image_datetime);
$capture_date = date($cfgrow['dateformat'],$capture_date);
Now the capture date will be formatted the same as the posted date. Note that this depends on your camera saving the date in a parsable format. Both my Olympus and Minolta do, so I expect it is ok.
__________________
shifted*exposure powered by PixelPost 1.4
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 11:03 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs