Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/include/exif_php.inc.php,v $
15
  $Revision: 1.7 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:11 $
18
**********************************************/
19
 
20
define("EXIF_CACHE_FILE","exif.dat");
21
require("include/exifReader.inc.php");
22
 
23
function exif_parse_file($filename)
24
{        global $CONFIG;
25
        if (!is_readable($filename)) return false;
26
        $size = @getimagesize($filename);
27
        if ($size[2] != 2) return false; // Not a JPEG file
28
 
29
        //Check if we have the data of the said file in the table
30
        $sql = "SELECT * FROM {$CONFIG['TABLE_EXIF']} ".
31
                  "WHERE filename = \"$filename\"";
32
 
33
        $result = db_query($sql);
34
 
35
        if (mysql_num_rows($result)){
36
                $row = mysql_fetch_array($result);
37
                mysql_free_result($result);
38
                $exifParsed = unserialize($row["exifData"]);
39
                return $exifParsed;
40
        }
41
 
42
        // No data in the table - read it from the image file
43
        $exifObj = new phpExifReader($filename);
44
        $exif = $exifObj->getImageInfo();
45
 
46
        $exifParsed = array();
47
 
48
        $Make = isset($exif['make']);
49
        $Model = isset($exif['model']);
50
 
51
        if (isset($exif['make']) && isset($exif['model'])){
52
                $exifParsed['Camera'] = trim($exif['make'])." - ".trim($exif['model']);
53
        }
54
 
55
        if (isset($exif['DateTime'])){
56
                $exifParsed['DateTaken'] = $exif['DateTime'];
57
        }
58
 
59
        if (isset($exif['fnumber'])){
60
                $exifParsed['Aperture'] = $exif['fnumber'];
61
        }
62
 
63
        if (isset($exif['exposureTime'])){
64
                $exifParsed['ExposureTime'] = $exif['exposureTime'];
65
        }
66
 
67
        if (isset($exif['focalLength'])){
68
                $exifParsed['FocalLength'] = $exif['focalLength'];
69
        }
70
 
71
        if (isset($exif['isoEquiv'])){
72
                $exifParsed['ISO'] = $exif['isoEquiv'];
73
        }
74
 
75
        if (isset($exif['exifComment'])){
76
                $comment = $exif['exifComment'];
77
                $exifParsed['Comment'] = $comment; // eregi_replace("ASCII"," ", $comment);
78
        }
79
 
80
        // Insert it into table for future reference
81
        $sql = "INSERT INTO {$CONFIG['TABLE_EXIF']} ".
82
                  "VALUES ('$filename', '".addslashes(serialize($exifParsed))."')";
83
 
84
        $result = db_query($sql);
85
 
86
        return $exifParsed;
87
}
88
?>