ExifExtractor.inc.php
1010 Bytes
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
<?php
class ExifExtractor extends DocumentExtractor
{
public function getDisplayName()
{
return _kt('Exif Extractor');
}
public function getSupportedMimeTypes()
{
return array(
'image/tiff','image/jpeg'
);
}
public function extractTextContent()
{
$exif = exif_read_data($this->sourcefile, 0, true);
$content = '';
foreach ($exif as $key => $section)
{
foreach ($section as $name => $val)
{
if (is_numeric($val))
{
// no point indexing numeric content. it will be ignored anyways!
continue;
}
if ($key =='FILE' && in_array($name, array('MimeType', 'SectionsFound')))
{
continue;
}
$content .= "$val\n";
}
}
$result = file_put_contents($this->targetfile, $content);
return false !== $result;
}
public function diagnose()
{
if (!function_exists('exif_read_data'))
{
return sprintf(_kt('The Exif extractor requires the module exif php extension. Please include this in the php.ini.'));
}
return null;
}
}
?>