aboutsummaryrefslogtreecommitdiff
path: root/www/inc/exif.inc.php
blob: be76168044ae7bce5384f10aee0122795a3255dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
if ($exif_prog=="php4") {
   // php internal handling
   // read_exif_data is supposed to read the whole jpeg into memory,
   // so we'll use the thumbnails to save it
   // THIS IS COMPLETELY UNTESTED!!!!
   $exif_array = read_exif_data("$thumb");
   if ($exif_style=="descriptive") {
      // fancy table look
      echo "<table border=\"0\" align=\"center\">\n";
      //co ukazat (podle exif_show
      if ($exif_show) {
         while(list($k,$v)=each($exif_array)) {
            while ($x = current($exif_show)) {
               if ($x==$k) {
                  echo "<tr>";
                  echo "<td align=\"right\">$k :</td>";
                  echo "<td><b>$v</b></td>";
                  echo "</tr>\n";
               }
               next($exif_show);
            }
         }
      } else {
         //ukaze vsechno
         while(list($k,$v)=each($exif_array)) {
            echo "<tr>";
            echo "<td align=\"right\">$k :</td>";
            echo "<td><b>$v</b></td>";
            echo "</tr>\n";
         }
      }
      echo "<tr>\n";
      echo "<td></td>";
      # only show if EXIF header exists
      if ($exif_array["Make"]) {
         echo "<td><a href=\"$ThisScript?galerie=$galerie&snimek=$snimek";
         echo "&exif_style=simple&show_thumbs=$show_thumbs\">";
         echo "<b>display line</b></a></td>\n";
      }
      echo "</tr>\n";
      echo "</table>\n";
      echo "</table>";
   } else {
      // in one line
      if ($exif_show) {
         while(list($k,$v)=each($exif_array)) {
            while ($x = current($exif_show)) {
               if ($x==$k) {
                  echo "$v | ";
               }
               next($exif_show);
            }
         }
      } else {
         while(list($k,$v)=each($exif_array)) {
            echo "$v | ";
         }
      }
      # only show if EXIF header exists
      if ($exif_array["Make"]) {
         echo "<a href=\"$ThisScript?galerie=$galerie&snimek=$snimek";
         echo "&exif_style=descriptive&show_thumbs=$show_thumbs\">";
         echo "<b>display table</b></a>\n";
         echo "</p>\n";
      }  
   }
   
} else {
   // the old code, handles e.g. metacam and jhead as EXIF extractors
   // loading lq means it won't work if the convertor doesn't copy EXIF data
   // (newer ImageMagick can)
   exec("$exif_prog \"$gallery_dir/$galerie/lq/img-$snimek.jpg\"", $exif_data, $exif_status);
   if ($exif_status!="2") {
      if ($exif_style=="descriptive") {
         // fancy table look
         echo "<table border=\"0\" align=\"center\">\n";
         while ($x = current($exif_data)) {
            eregi("^ *([^:]*): *(.*)", $x, $y);
            //filter according to $exif_show array
            if (!$exif_show) { //all fields shown
                     echo "<tr>";
                     echo "<td align=\"right\">$y[1] :</td>";
                     echo "<td><b>$y[2]</b></td>";
                     echo "</tr>\n";
            } else {
               reset($exif_show);
               while ($z = current($exif_show)) {
                  //echo ".$z. ::: .$y[1].<br>";
		  if (trim($z) == trim($y[1])) {
                     echo "<tr>";
                     echo "<td align=\"right\">$y[1] :</td>";
                     echo "<td><b>$y[2]</b></td>";
                     echo "</tr>\n";
                  }
               next($exif_show);
               }
            }
            next($exif_data);
         }
         echo "<tr>\n";
         echo "<td></td>";
      # only show if EXIF header exists
      if ($y[1]!="File") { // don't show when no EXIF
            echo "<td><a href=\"$ThisScript?galerie=$galerie&snimek=$snimek";
            echo "&exif_style=simple&show_thumbs=$show_thumbs\">";
            echo "<b>display line</b></a></td>\n";
      }
         echo "</tr>\n";
         echo "</table>\n";
      } else {
         //simple plaintext look
         echo "<p class=\"exif\" align=\"center\">";
         while ($x = current($exif_data)) {
            eregi("^ *([^:]*): *(.*)", $x, $y);
            if (!$exif_show) { //all fields shown
               echo "$y[2] |";
            } else {
               reset($exif_show);
               while ($z = current($exif_show)) {
		  if (trim($z) == trim($y[1])) {
                     echo "$y[2] | ";
                  }
                  next($exif_show);
               }
            }
            next($exif_data);
         }
         # only show if EXIF header exists
         if ($y[1]!="File") {
            echo "<a href=\"$ThisScript?galerie=$galerie&snimek=$snimek";
            echo "&exif_style=descriptive&show_thumbs=$show_thumbs\">";
            echo "<b>display table</b></a>\n";
            echo "</p>\n";
         }
      }
   }
}
?>