4 * PEL: PHP Exif Library. A library with support for reading and
5 * writing all Exif headers in JPEG and TIFF images using PHP.
7 * Copyright (C) 2005, 2006 Martin Geisler.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program in the file COPYING; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22 * Boston, MA 02110-1301 USA
26 use lsolesen\pel\PelJpeg;
28 class NikonCoolscanIVTest extends \PHPUnit_Framework_TestCase
30 public function testRead()
32 Pel::clearExceptions();
33 Pel::setStrictParsing(false);
34 $jpeg = new PelJpeg(dirname(__FILE__) . '/nikon-coolscan-iv.jpg');
36 $exif = $jpeg->getExif();
37 $this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
39 $tiff = $exif->getTiff();
40 $this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
43 $ifd0 = $tiff->getIfd();
44 $this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
46 /* Start of IDF $ifd0. */
47 $this->assertEquals(count($ifd0->getEntries()), 6);
49 $entry = $ifd0->getEntry(271); // Make
50 $this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
51 $this->assertEquals($entry->getValue(), 'Nikon');
52 $this->assertEquals($entry->getText(), 'Nikon');
54 $entry = $ifd0->getEntry(282); // XResolution
55 $this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
56 $this->assertEquals($entry->getValue(), array(
60 $this->assertEquals($entry->getText(), '2000/1');
62 $entry = $ifd0->getEntry(283); // YResolution
63 $this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
64 $this->assertEquals($entry->getValue(), array(
68 $this->assertEquals($entry->getText(), '2000/1');
70 $entry = $ifd0->getEntry(296); // ResolutionUnit
71 $this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
72 $this->assertEquals($entry->getValue(), 2);
73 $this->assertEquals($entry->getText(), 'Inch');
75 $entry = $ifd0->getEntry(306); // DateTime
76 $this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
77 $this->assertEquals($entry->getValue(), 1090023875);
78 $this->assertEquals($entry->getText(), '2004:07:17 00:24:35');
80 $entry = $ifd0->getEntry(531); // YCbCrPositioning
81 $this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
82 $this->assertEquals($entry->getValue(), 1);
83 $this->assertEquals($entry->getText(), 'centered');
85 /* Sub IFDs of $ifd0. */
86 $this->assertEquals(count($ifd0->getSubIfds()), 2);
87 $ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
88 $this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
90 /* Start of IDF $ifd0_0. */
91 $this->assertEquals(count($ifd0_0->getEntries()), 7);
93 $entry = $ifd0_0->getEntry(36864); // ExifVersion
94 $this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
95 $this->assertEquals($entry->getValue(), 2.1);
96 $this->assertEquals($entry->getText(), 'Exif Version 2.1');
98 $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
99 $this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
100 $this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
101 $this->assertEquals($entry->getText(), 'Y Cb Cr -');
103 $entry = $ifd0_0->getEntry(37500); // MakerNote
104 $this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
105 $expected = "\x02\0\x01\0\x07\0\x04\0\0\0\x30\x31\x30\x30\x10\x0e\x04\0\x01\0\0\0\x16\x01\0\0\0\0\0\0\x05\0";
106 $this->assertEquals($entry->getValue(), $expected);
107 $this->assertEquals($entry->getText(), '32 bytes unknown MakerNote data');
109 $entry = $ifd0_0->getEntry(40960); // FlashPixVersion
110 $this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
111 $this->assertEquals($entry->getValue(), 1);
112 $this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
114 $entry = $ifd0_0->getEntry(40961); // ColorSpace
115 $this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
116 $this->assertEquals($entry->getValue(), 1);
117 $this->assertEquals($entry->getText(), 'sRGB');
119 $entry = $ifd0_0->getEntry(40962); // PixelXDimension
120 $this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
121 $this->assertEquals($entry->getValue(), 960);
122 $this->assertEquals($entry->getText(), '960');
124 $entry = $ifd0_0->getEntry(40963); // PixelYDimension
125 $this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
126 $this->assertEquals($entry->getValue(), 755);
127 $this->assertEquals($entry->getText(), '755');
129 /* Sub IFDs of $ifd0_0. */
130 $this->assertEquals(count($ifd0_0->getSubIfds()), 0);
132 $this->assertEquals($ifd0_0->getThumbnailData(), '');
135 $ifd0_1 = $ifd0_0->getNextIfd();
136 $this->assertNull($ifd0_1);
137 /* End of IFD $ifd0_0. */
138 $ifd0_1 = $ifd0->getSubIfd(3); // IFD GPS
139 $this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_1);
141 /* Start of IDF $ifd0_1. */
142 $this->assertEquals(count($ifd0_1->getEntries()), 0);
144 /* Sub IFDs of $ifd0_1. */
145 $this->assertEquals(count($ifd0_1->getSubIfds()), 0);
147 $this->assertEquals($ifd0_1->getThumbnailData(), '');
150 $ifd0_2 = $ifd0_1->getNextIfd();
151 $this->assertNull($ifd0_2);
152 /* End of IFD $ifd0_1. */
154 $this->assertEquals($ifd0->getThumbnailData(), '');
157 $ifd1 = $ifd0->getNextIfd();
158 $this->assertNull($ifd1);
159 /* End of IFD $ifd0. */
161 $this->assertTrue(count(Pel::getExceptions()) == 0);