ryxeo-webphotoalbum-git / data / www / inc / exif.inc.php @ 7938c308
Historique | Voir | Annoter | Télécharger (3,05 ko)
1 |
<?php
|
---|---|
2 |
|
3 |
|
4 |
function formatEXIF ($k,$v) { |
5 |
// format some special cases
|
6 |
// dunno if EXIF support formats it so weirdly everywhere.
|
7 |
// Sure does in my php4
|
8 |
|
9 |
switch ($k) { |
10 |
case "FocalLength": |
11 |
$out = eval("return $v;"); |
12 |
$out .= "mm"; |
13 |
return $out; |
14 |
break;
|
15 |
case "FNumber": |
16 |
$out = "f/"; |
17 |
$out .= eval("return $v;"); |
18 |
return $out; |
19 |
break;
|
20 |
case "ExposureTime": |
21 |
// numerator = cistatel; jmenovatel = denominator :)
|
22 |
$x = explode("/",$v,2); |
23 |
if ($x[0]>=100) { |
24 |
$out = eval("return ${x[0]}/${x[1]};"); |
25 |
$out .= "s"; |
26 |
return $out; |
27 |
} else {
|
28 |
return "1/".(1.0/($x[0]/$x[1]))."s"; |
29 |
} |
30 |
break;
|
31 |
case "Flash"; |
32 |
if ($v=="0") { |
33 |
return "No Flash"; |
34 |
} else {
|
35 |
return $v; |
36 |
} |
37 |
break;
|
38 |
case "ISOSpeedRatings": |
39 |
return "ISO" . $v; |
40 |
break;
|
41 |
case "GainControl"; |
42 |
return "EV" . $v; |
43 |
break;
|
44 |
case "FocalLengthIn35mmFilm": |
45 |
return $v . "mm"; |
46 |
break;
|
47 |
case "DateTime": |
48 |
//return date("M d Y H:i:s", $v);
|
49 |
ereg("^([0-9]{4}):([0-9]{1,2}):([0-9]{1,2}) (.*)",$v,$x); |
50 |
return $x[1] . "/" . $x[2] . "/" . $x[3] . " " . $x[4]; |
51 |
break;
|
52 |
default:
|
53 |
return $v; |
54 |
} |
55 |
} |
56 |
|
57 |
|
58 |
// Only use php4 internal handling now.
|
59 |
// $file is LQ image
|
60 |
$exif_array = exif_read_data("$file"); |
61 |
reset($exif_array); |
62 |
if ($exif_show) reset($exif_show); |
63 |
|
64 |
if ($exif_array["Make"]) { // only render all this |
65 |
// if there is EXIF header
|
66 |
// fancy table look
|
67 |
echo "<div id=\"exif_table\" style=\"display: none;\">\n"; |
68 |
echo "<table class=\"exif\" border=\"0\">\n"; |
69 |
//co ukazat (podle exif_show)
|
70 |
if ($exif_show) { |
71 |
while (list($kx,$x) = each($exif_show)) { |
72 |
while(list($k,$v)=each($exif_array)) { |
73 |
if ($kx==$k) { |
74 |
echo "<tr>"; |
75 |
echo "<td align=\"right\">"; |
76 |
echo $x; |
77 |
echo ": </td>"; |
78 |
echo "<td><b>"; |
79 |
echo formatEXIF($k,$v); |
80 |
echo "</b></td>"; |
81 |
echo "</tr>\n"; |
82 |
} |
83 |
} |
84 |
reset($exif_array); |
85 |
} |
86 |
} else {
|
87 |
//ukaze vsechno v tabulce
|
88 |
while(list($k,$v)=each($exif_array)) { |
89 |
echo "<tr>"; |
90 |
echo "<td align=\"right\">"; |
91 |
echo $k; |
92 |
echo ": </td>"; |
93 |
echo "<td><b>"; |
94 |
echo formatEXIF($k,$v); |
95 |
echo "</b></td>"; |
96 |
echo "</tr>\n"; |
97 |
} |
98 |
} |
99 |
echo "<tr>\n"; |
100 |
echo "<td></td>"; |
101 |
echo "<td><a href=\"javascript:toggle_div('exif_table');toggle_div('exif_line');\">" . __("Less info"); |
102 |
echo "</a></td>"; |
103 |
echo "</tr>\n"; |
104 |
echo "</table>\n"; |
105 |
echo "</div>\n"; |
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
// selected EXIF header on one line
|
112 |
echo "<div id=\"exif_line\">\n"; |
113 |
echo "<p class=\"exif\">"; |
114 |
reset($exif_array); |
115 |
if ($exif_show) reset($exif_show); |
116 |
if ($exif_show) { |
117 |
while (list($kx,$x) = each($exif_show)) { |
118 |
while(list($k,$v)=each($exif_array)) { |
119 |
if ($kx==$k) { |
120 |
echo "<span title=\"$x\">"; |
121 |
echo formatEXIF($k,$v); |
122 |
echo "</span> | "; |
123 |
} |
124 |
} |
125 |
reset($exif_array); |
126 |
} |
127 |
} else {
|
128 |
/* vsechny exif headers inline */
|
129 |
while(list($k,$v)=each($exif_array)) { |
130 |
echo "<span title=\""; |
131 |
echo $k; |
132 |
echo "\">"; |
133 |
echo formatEXIF($k,$v); |
134 |
echo "</span> | "; |
135 |
} |
136 |
} |
137 |
|
138 |
echo "<a href=\"javascript:toggle_div('exif_table');toggle_div('exif_line');\">" . __("More info"); |
139 |
echo "</a></p>\n"; |
140 |
echo "</div>\n"; |
141 |
} |
142 |
|
143 |
?>
|