forked from evanhunter/PJMT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_casio_thumb.php
128 lines (108 loc) · 5.06 KB
/
get_casio_thumb.php
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
<?php
/******************************************************************************
*
* Filename: get_ps_thumb.php
*
* Description: This script extracts a Casio Type 2 EXIF Makernote Thumbnail
* from within a JPEG file and allows it to be displayed
*
* Usage: get_casio_thumb?filename=<filename>
*
* Author: Evan Hunter
*
* Date: 23/7/2004
*
* Project: PHP JPEG Metadata Toolkit
*
* Revision: 1.12
*
* Changes: 1.00 -> 1.12 : changed to use _GET variable
*
* URL: http://electronics.ozhiker.com
*
* Copyright: Copyright Evan Hunter 2004
*
* License: This file is part of the PHP JPEG Metadata Toolkit.
*
* The PHP JPEG Metadata Toolkit is free software; you can
* redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* The PHP JPEG Metadata Toolkit is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public
* License along with the PHP JPEG Metadata Toolkit; if not,
* write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*
* If you require a different license for commercial or other
* purposes, please contact the author: [email protected]
*
******************************************************************************/
// Ensure that nothing can write to the standard io, before we get the header out
ob_start( );
include 'EXIF.php';
// retrieve the filename from the URL parameters
$filename = $_GET['filename'];
// Retrieve any EXIF data in the file
$Exif_array = get_EXIF_JPEG( $filename );
// Check if any EXIF data was retrieved
if ( $Exif_array === FALSE )
{
// No EXIF data was found - abort
ob_end_clean ( );
echo "<p>Error getting EXIF Information</p>\n";
return;
}
// Check that there is at least the Zeroth IFD in the array
if ( count( $Exif_array ) < 1 )
{
// Couldn't find the zeroth IFD
return;
}
// Check that the EXIF IFD exists
if ( array_key_exists( 34665, $Exif_array[0] ) )
{
// Found the EXIF IFD,
// Check that the makernote tag exists
if ( array_key_exists( 37500, $Exif_array[0][34665]['Data'][0] ) )
{
// Makernote Exists
// Check that the Makernote is Casio Type 2
if ( $Exif_array[0][34665]['Data'][0][37500]['Makernote Tags'] == "Casio Type 2" )
{
// Makernote is Casio Type 2
// Check if an IFD exists for the makernote
if ( array_key_exists( 0, $Exif_array[0][34665]['Data'][0][37500]['Decoded Data'] ) )
{
// Check if the Thumbnail offset tag 8192 exists
if ( array_key_exists( 8192, $Exif_array[0][34665]['Data'][0][37500]['Decoded Data'][0] ) )
{
// Found Thumbnail - Display it
ob_end_clean ( );
header("Content-type: image/jpeg");
print $Exif_array[0][34665]['Data'][0][37500]['Decoded Data'][0][8192]['Data'];
}
// Check if the Thumbnail offset tag 4 exists
else if ( array_key_exists( 4, $Exif_array[0][34665]['Data'][0][37500]['Decoded Data'][0] ) )
{
// Found Thumbnail - Display it
ob_end_clean ( );
header("Content-type: image/jpeg");
print $Exif_array[0][34665]['Data'][0][37500]['Decoded Data'][0][4]['Data'];
}
}
}
}
}
else
{
}
return;
?>