PDA

View Full Version : Mod for EXIF / copied from other not adequate posting


Connie
03-02-2005, 09:50 PM
this message was added by the user "commando"
sorry, I had to copy this posting and place it here :cry:
===================


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)

// 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);
}

Connie
03-03-2005, 05:58 AM
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.

// 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]

Rob
03-04-2005, 06:10 PM
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...

GregWilkerPhoto
03-05-2005, 04:13 AM
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... =\

Rob
03-07-2005, 08:05 PM
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.

raminia
03-07-2005, 08:53 PM
@Commando
Nice Avatar! :)

marlyse
03-09-2005, 12:49 AM
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.

n0d3
03-10-2005, 07:06 AM
Is there anyway to format the way the date/time turns out?

Connie
03-10-2005, 08:33 AM
did you try the date-format-option in the admin panel ?

Rob
03-10-2005, 01:40 PM
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.)

$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.

Anonymous
03-24-2005, 05:14 PM
Exif Data Display Edit Text mod...

Now, I dont know how to right php so i dont know how hard this would be but. I was thinking of this addon to the admin/newimage upload etc.

have a new text field that has a button above it that is "get exif" when you click on that it puts the exif data into the text field to edit or add a link any of your exif data. so if you want to change the exif data or if you use a lens that isnt digital you can add its name.

so have two tag like <EXIF_DATA> for your templates

im currently making a drawing in photoshop on how this should look in the admin/image
if someone would like to write the code for this that would be great. while im trying to learn php

Rob
03-24-2005, 05:57 PM
It is better to do this before you upload your photo. It will be VERY hard to modify the images EXIF data using php, so I doubt most of us will ever find the time to tackle it. Sorry :cry:

GregWilkerPhoto
03-24-2005, 07:44 PM
its gregw

no i dont want to mod that data in the image

just how it is displayed



click "get data" in the new image upload admin part that would be added in the text area it will display the Exif data from the image. from there you can edit the text to how you want it to look like

example
currently display:
Canon EOS-1D Mark II, Exposure: 1/8000, Aperture: f/1.4, Focal: 50/1 mm,

thats what would pop up in the text field in the admin image exif area

what i want to add is a link to the canon eos-1d markii but just on this image

Canon EOS-1D Mark II (http://canon.com), Exposure: 1/8000, Aperture: f/1.4, Focal: 50/1 mm,