Discussion
Sort images by EXIF data?(back to index)Is it somehow possible to sort the images in Folderblog 3 by the EXIF information? And if not, is there any software available that can automatically adjust the file date to the EXIF data?
posted by ikue on 15 Sep 05 at 1:39 PM
The solution I finally programmed myself is so easy and simple that I really wonder why these 5 lines of code are not already integrated in Folgerblog...
posted by
anon on 29 Sep 05 at 8:59 AM
ikue
can you post/share the 5 lines to get this working?
thanks
richard
I would also like to see this...
posted by
akatsuki on 30 Sep 05 at 5:20 PM
Of course I can :)
function cmpexiftime($a, $b) {
$exif1 = exif_read_data($a, 0, true);
$exif2 = exif_read_data($b, 0, true);
if ($exif1["EXIF"]["DateTimeOriginal"]==$exif2["EXIF"]["DateTimeOriginal"]) {
return 0;
}
return $exif1["EXIF"]["DateTimeOriginal"] < $exif2["EXIF"]["DateTimeOriginal"] ? -1 : 1;
}
You simply have to include these lines in fb.php, and replace the existing line
uksort($files,"cmpmtime");
by
uksort($files,"cmpexiftime");
Thatīs it... ikue
posted by
ikue on 4 Oct 05 at 5:22 AM
ikue,
Tried the code you provided but got about a dozen error messages like this:
Notice: Undefined index: DateTimeOriginal in /mnt/web_g/d03/s49/b021eca5/www/folderblog/fb.php on line 176
Notice: Undefined index: DateTimeOriginal in /mnt/web_g/d03/s49/b021eca5/www/folderblog/fb.php on line 179
Notice: Undefined index: DateTimeOriginal in /mnt/web_g/d03/s49/b021eca5/www/folderblog/fb.php on line 176
Notice: Undefined index: DateTimeOriginal in /mnt/web_g/d03/s49/b021eca5/www/folderblog/fb.php on line 179
http://www.frhendrix.com/folderblog/fb.php
Any idea what I did wrong?
thanks
richard
Hmm... sounds like a problem with the variables. Just in advance, does the EXIF-function work in general on your server? So, if you include the EXIF extension, can you read out the additional image information?
I use folderblog 3, last beta
posted by anon on 5 Oct 05 at 6:28 AM
I'm using FB 3.16b, the last beta. EXIF displays correctly as is... See it here http://www.frhendrix.com/folderblog/fb.php I have it set up in a test folder before I move it to my normal server area. I have noticed that it does not show ISO but I think that is a Canon camera thing...
thanks
richard
The code you posted works great, ikue. Thanks.
But would somebody help me reverse the order? I would like to have the newest photo last, so that you get a slide show in chronological order.
Sorry I don't have the slightest idea of programming, but I hope this can be done with a single variable or something.
Thank you
posted by
Gernot on 6 Oct 05 at 10:47 AM
Gernot, try changing in line
return $exif1["EXIF"]["DateTimeOriginal"] < $exif2["EXIF"]["DateTimeOriginal"] ? -1 : 1;
the "<" into ">". Tell me if I am wrong, as it is late in Barcelona city. ;)
Richard, have you changed anything in the folderblog 3 files? As it works with Gernot, it should also be working with you. Maybe you try a "reinstallation" of my lines. Check if you followed the instructions. What I wondered about, are you sure you read out EXIF on your website? it looks more like the information is already put in the image, and not dynamically extracted from JPEG.
posted by
ikue on 6 Oct 05 at 6:25 PM
The hack work cool!
posted by
Tobias on 7 Oct 05 at 9:31 AM
I propose we include it in the next beta of folderblog... a nasty little extra feature, he? ;)
posted by
ikue on 7 Oct 05 at 11:59 AM
ikue,
I compared my fb.php with a fresh fb.php and both are the same except I added code to make the gravatar hack work. I am using the almanac template (3.16) for Folderblog.
EXIF is showing up in my information area for each photo. So I guess it is compiled into the sever software.
In your fb_settings.php file what setting are you using for $sort=0 ? I sort by file modified date.
Thanks for helping,
richard
Also, yes I have reinstalled your code and still no joy... I will try again.
Is there a way to convert this code to an extension?
richard
Thanks very much, ikue! It works perfectly.
I agree that this should be integrated into folderblog.
posted by
Gernot on 7 Oct 05 at 4:27 PM
Richard, I also have $sort = 0, so this can't be it. And no, there is in my opinion no way to convert this into an extension as it requires changes deep inside the fb.php. Suggestion: Mail me your fb.php, maybe I can have a quick look at it. Write to bjoern (dummy text, here has to be the "at") ikue.de
posted by
ikue on 10 Oct 05 at 5:58 AM
The problem is fairly obvious. You have at least some files with no exif data (or at least not a date). So obviously the index will be invalid. I'm having the same problem. Solution to follow. :)
posted by
Enki on 28 Apr 06 at 11:22 PM
Well, the problem was fairly simple. Just a matter of checking if exif_read_data actually produces exif data, and if the exif data we are interested in is in the array. Really this should've been done in the first place. ;) Seems to work well now. Enjoy!
Replace the above function definition with these two functions.
function exifdate($file) {
$exif = exif_read_data($file, 0, true);
if (array_key_exists("EXIF", $exif)) {
if (array_key_exists("DateTimeOriginal", $exif["EXIF"])) {
return $exif["EXIF"]["DateTimeOriginal"];
}
}
return date ("Y:m:d H:i:s", filemtime($file)) ;
}
function cmpexiftime($a, $b) {
$date1 = exifdate($a);
$date2 = exifdate($b);
if ( $date1 == $date2 ) {
return 0;
}
return $date1 < $date2 ? -1 : 1;
}
posted by
Enki on 29 Apr 06 at 12:29 AM
Now heres one to add to this code: Can anyone write the EXIF date into the normal date box that appears in /post/?
posted by
sean on 16 May 06 at 12:50 AM
Hello Sean, not much of a problem.... look out in fb.php for the line
filemtime($fbimage[1])+$time_difference)
(it appears twice, go to the first one).
Now you have two substitute the part of
filemtime($fbimage[1])
by
$exif["EXIF"]["DateTimeOriginal"]
as mentioned above by Enki. What is left is to include one line BEFORE the $fbpostform = xxxxxxxxxx the line
$exif = exif_read_data($fbimage[1], 0, true);
to read out the necessary information. Any questions? ;)
PS: Of course the code might not work directly from the start as I didnt test it! But the idea is clear.
posted by
ikue on 25 May 06 at 12:04 AM
Hummm i've got a problem wint fb_exif.php extension, this extension said that i use alerady the flash but it's wrong ! It's a problem because this information is not true :-((( What can i do please ? Help me !!!! HHEELLPP MMEE !!! ;-)
posted by
ZACHES on 6 Sep 06 at 12:59 PM
Got me on that. Thanks for the solution provided above. It saved me some hours of trial and error.
I compared my fb.php with a fresh fb.php and both are the same except I added code to make the gravatar hack work. I am using the almanac template (3.16) for Folderblog. Thanks anyway for the solutions.
Post a Reply:
(back to index)