default services conflit ?

This commit is contained in:
armansansd
2022-04-27 11:30:43 +02:00
parent 28190a5749
commit 8bb1064a3b
8132 changed files with 900138 additions and 426 deletions

View File

@@ -0,0 +1 @@
/config.local.php

View File

@@ -0,0 +1,128 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006, 2007 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelConvert;
use lsolesen\pel\PelEntryAscii;
use lsolesen\pel\PelEntryCopyright;
use lsolesen\pel\PelEntryTime;
use lsolesen\pel\PelFormat;
use lsolesen\pel\PelTag;
use PHPUnit\Framework\TestCase;
class AsciiTest extends TestCase
{
public function testReturnValues()
{
$entry = new PelEntryAscii(42);
$entry = new PelEntryAscii(42, 'foo bar baz');
$this->assertEquals($entry->getFormat(), PelFormat::ASCII);
$this->assertEquals($entry->getComponents(), 12);
$this->assertEquals($entry->getValue(), 'foo bar baz');
}
public function testTime()
{
$entry = new PelEntryTime(PelTag::DATE_TIME_ORIGINAL, 10);
$this->assertEquals($entry->getFormat(), PelFormat::ASCII);
$this->assertEquals($entry->getTag(), PelTag::DATE_TIME_ORIGINAL);
$this->assertEquals($entry->getComponents(), 20);
$this->assertEquals($entry->getValue(), 10);
$this->assertEquals($entry->getValue(PelEntryTime::UNIX_TIMESTAMP), 10);
$this->assertEquals($entry->getValue(PelEntryTime::EXIF_STRING), '1970:01:01 00:00:10');
$this->assertEquals($entry->getValue(PelEntryTime::JULIAN_DAY_COUNT), 2440588 + 10 / 86400);
$this->assertEquals($entry->getText(), '1970:01:01 00:00:10');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '1970:01:01 00:00:10' . chr(0x00));
// Malformed Exif timestamp.
$entry->setValue('1970!01-01 00 00 30', PelEntryTime::EXIF_STRING);
$this->assertEquals($entry->getValue(), 30);
$entry->setValue(2415021.75, PelEntryTime::JULIAN_DAY_COUNT);
// This is Jan 1st 1900 at 18:00, outside the range of a UNIX
// timestamp:
$this->assertEquals($entry->getValue(), false);
$this->assertEquals($entry->getValue(PelEntryTime::EXIF_STRING), '1900:01:01 18:00:00');
$this->assertEquals($entry->getValue(PelEntryTime::JULIAN_DAY_COUNT), 2415021.75);
$entry->setValue('0000:00:00 00:00:00', PelEntryTime::EXIF_STRING);
$this->assertEquals($entry->getValue(), false);
$this->assertEquals($entry->getValue(PelEntryTime::EXIF_STRING), '0000:00:00 00:00:00');
$this->assertEquals($entry->getValue(PelEntryTime::JULIAN_DAY_COUNT), 0);
$entry->setValue('9999:12:31 23:59:59', PelEntryTime::EXIF_STRING);
// this test will fail on 32bit machines
$this->assertEquals($entry->getValue(), 253402300799);
$this->assertEquals($entry->getValue(PelEntryTime::EXIF_STRING), '9999:12:31 23:59:59');
$this->assertEquals($entry->getValue(PelEntryTime::JULIAN_DAY_COUNT), 5373484 + 86399 / 86400);
// Check day roll-over for SF bug #1699489.
$entry->setValue('2007:04:23 23:30:00', PelEntryTime::EXIF_STRING);
$t = $entry->getValue(PelEntryTime::UNIX_TIMESTAMP);
$entry->setValue($t + 3600);
$this->assertEquals($entry->getValue(PelEntryTime::EXIF_STRING), '2007:04:24 00:30:00');
}
public function testCopyright()
{
$entry = new PelEntryCopyright();
$this->assertEquals($entry->getFormat(), PelFormat::ASCII);
$this->assertEquals($entry->getTag(), PelTag::COPYRIGHT);
$value = $entry->getValue();
$this->assertEquals($value[0], '');
$this->assertEquals($value[1], '');
$this->assertEquals($entry->getText(false), '');
$this->assertEquals($entry->getText(true), '');
$entry->setValue('A');
$value = $entry->getValue();
$this->assertEquals($value[0], 'A');
$this->assertEquals($value[1], '');
$this->assertEquals($entry->getText(false), 'A (Photographer)');
$this->assertEquals($entry->getText(true), 'A');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), 'A' . chr(0));
$entry->setValue('', 'B');
$value = $entry->getValue();
$this->assertEquals($value[0], '');
$this->assertEquals($value[1], 'B');
$this->assertEquals($entry->getText(false), 'B (Editor)');
$this->assertEquals($entry->getText(true), 'B');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), ' ' . chr(0) . 'B' . chr(0));
$entry->setValue('A', 'B');
$value = $entry->getValue();
$this->assertEquals($value[0], 'A');
$this->assertEquals($value[1], 'B');
$this->assertEquals($entry->getText(false), 'A (Photographer) - B (Editor)');
$this->assertEquals($entry->getText(true), 'A - B');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), 'A' . chr(0) . 'B' . chr(0));
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006, 2007 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelIllegalFormatException;
use lsolesen\pel\PelJpeg;
class BrokenImagesTest extends TestCase
{
public function testWindowWindowExceptionIsCaught()
{
$jpeg = new PelJpeg(dirname(__FILE__) . '/broken_images/gh-10-a.jpg');
$this->assertInstanceOf('\lsolesen\pel\PelJpeg', $jpeg);
}
public function testWindowOffsetExceptionIsCaught()
{
$jpeg = new PelJpeg(dirname(__FILE__) . '/broken_images/gh-10-b.jpg');
$this->assertInstanceOf('\lsolesen\pel\PelJpeg', $jpeg);
}
public function testParsingNotFailingOnRecursingIfd()
{
$jpeg = new PelJpeg(dirname(__FILE__) . '/broken_images/gh-11.jpg');
$this->assertInstanceOf('\lsolesen\pel\PelJpeg', $jpeg);
}
public function testInvalidIfd()
{
$this->expectException(PelIllegalFormatException::class) ;
$jpeg = new PelJpeg(dirname(__FILE__) . '/broken_images/gh-156.jpg');
$this->assertInstanceOf('\lsolesen\pel\PelJpeg', $jpeg);
}
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006, 2007 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use Exception;
use lsolesen\pel\PelJpeg;
use lsolesen\pel\PelExif;
use lsolesen\pel\PelTiff;
use lsolesen\pel\PelIfd;
use lsolesen\pel\PelTag;
use lsolesen\pel\PelEntryAscii;
use PHPUnit\Framework\TestCase;
class Bug3017880Test extends TestCase
{
public function testThisDoesNotWorkAsExpected()
{
$filename = dirname(__FILE__) . '/images/bug3017880.jpg';
try {
$exif = null;
$resave_file = 0;
$jpeg = new PelJpeg($filename);
$this->assertInstanceOf('\lsolesen\pel\PelJpeg', $jpeg);
// should all exif data on photo be cleared (gd and iu will always strip it anyway, so only
// force strip if you know the image you're branding is an original)
// $jpeg->clearExif();
if ($exif === null) {
$exif = new PelExif();
$jpeg->setExif($exif);
$tiff = new PelTiff();
$exif->setTiff($tiff);
}
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
if ($ifd0 === null) {
$ifd0 = new PelIfd(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
$software_name = 'Example V2';
$software = $ifd0->getEntry(PelTag::SOFTWARE);
if ($software === null) {
$software = new PelEntryAscii(PelTag::SOFTWARE, $software_name);
$ifd0->addEntry($software);
$resave_file = 1;
} else {
$software->setValue($software_name);
$resave_file = 1;
}
if ($resave_file == 1 && ! file_put_contents($filename, $jpeg->getBytes())) {
// if it was okay to resave the file, but it did not save correctly
}
} catch (Exception $e) {
$this->fail('Test should not throw an exception');
}
}
}

View File

@@ -0,0 +1,245 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelConvert;
use PHPUnit\Framework\TestCase;
class ConvertTest extends TestCase
{
private $bytes = "\x00\x00\x00\x00\x01\x23\x45\x67\x89\xAB\xCD\xEF\xFF\xFF\xFF\xFF";
public function testLongLittle()
{
$o = PelConvert::LITTLE_ENDIAN;
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 0, $o), 0x00000000);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 1, $o), 0x01000000);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 2, $o), 0x23010000);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 3, $o), 0x45230100);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 4, $o), 0x67452301);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 5, $o), 0x89674523);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 6, $o), 0xAB896745);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 7, $o), 0xCDAB8967);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 8, $o), 0xEFCDAB89);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 9, $o), 0xFFEFCDAB);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 10, $o), 0xFFFFEFCD);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 11, $o), 0xFFFFFFEF);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 12, $o), 0xFFFFFFFF);
}
public function testLongBig()
{
$o = PelConvert::BIG_ENDIAN;
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 0, $o), 0x00000000);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 1, $o), 0x00000001);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 2, $o), 0x00000123);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 3, $o), 0x00012345);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 4, $o), 0x01234567);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 5, $o), 0x23456789);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 6, $o), 0x456789AB);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 7, $o), 0x6789ABCD);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 8, $o), 0x89ABCDEF);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 9, $o), 0xABCDEFFF);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 10, $o), 0xCDEFFFFF);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 11, $o), 0xEFFFFFFF);
$this->assertEquals(PelConvert::bytesToLong($this->bytes, 12, $o), 0xFFFFFFFF);
}
public function testSLongLittle()
{
// TODO: Does not work on 64bit systems!
$this->markTestIncomplete('Does not work on 64bit systems!');
$o = PelConvert::LITTLE_ENDIAN;
/*
* The easiest way to calculate the numbers to compare with, is to
* let PHP do the arithmetic for us. When using the bit-wise
* operators PHP will return a proper signed 32 bit integer.
*/
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 0, $o), 0x00 << 24 | 0x00 << 16 | 0x00 << 8 | 0x00);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 1, $o), 0x01 << 24 | 0x00 << 16 | 0x00 << 8 | 0x00);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 2, $o), 0x23 << 24 | 0x01 << 16 | 0x00 << 8 | 0x00);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 3, $o), 0x45 << 24 | 0x23 << 16 | 0x01 << 8 | 0x00);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 4, $o), 0x67 << 24 | 0x45 << 16 | 0x23 << 8 | 0x01);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 5, $o), 0x89 << 24 | 0x67 << 16 | 0x45 << 8 | 0x23);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 6, $o), 0xAB << 24 | 0x89 << 16 | 0x67 << 8 | 0x45);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 7, $o), 0xCD << 24 | 0xAB << 16 | 0x89 << 8 | 0x67);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 8, $o), 0xEF << 24 | 0xCD << 16 | 0xAB << 8 | 0x89);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 9, $o), 0xFF << 24 | 0xEF << 16 | 0xCD << 8 | 0xAB);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 10, $o), 0xFF << 24 | 0xFF << 16 | 0xEF << 8 | 0xCD);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 11, $o), 0xFF << 24 | 0xFF << 16 | 0xFF << 8 | 0xEF);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 12, $o), 0xFF << 24 | 0xFF << 16 | 0xFF << 8 | 0xFF);
}
public function testSLongBig()
{
// TODO: Does not work on 64bit systems
$this->markTestIncomplete('Does not work on 64bit systems!');
$o = PelConvert::BIG_ENDIAN;
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 0, $o), 0x00 << 24 | 0x00 << 16 | 0x00 << 8 | 0x00);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 1, $o), 0x00 << 24 | 0x00 << 16 | 0x00 << 8 | 0x01);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 2, $o), 0x00 << 24 | 0x00 << 16 | 0x01 << 8 | 0x23);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 3, $o), 0x00 << 24 | 0x01 << 16 | 0x23 << 8 | 0x45);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 4, $o), 0x01 << 24 | 0x23 << 16 | 0x45 << 8 | 0x67);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 5, $o), 0x23 << 24 | 0x45 << 16 | 0x67 << 8 | 0x89);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 6, $o), 0x45 << 24 | 0x67 << 16 | 0x89 << 8 | 0xAB);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 7, $o), 0x67 << 24 | 0x89 << 16 | 0xAB << 8 | 0xCD);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 8, $o), 0x89 << 24 | 0xAB << 16 | 0xCD << 8 | 0xEF);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 9, $o), 0xAB << 24 | 0xCD << 16 | 0xEF << 8 | 0xFF);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 10, $o), 0xCD << 24 | 0xEF << 16 | 0xFF << 8 | 0xFF);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 11, $o), 0xEF << 24 | 0xFF << 16 | 0xFF << 8 | 0xFF);
$this->assertEquals(PelConvert::bytesToSLong($this->bytes, 12, $o), 0xFF << 24 | 0xFF << 16 | 0xFF << 8 | 0xFF);
}
public function testShortLittle()
{
$o = PelConvert::LITTLE_ENDIAN;
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 0, $o), 0x0000);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 1, $o), 0x0000);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 2, $o), 0x0000);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 3, $o), 0x0100);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 4, $o), 0x2301);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 5, $o), 0x4523);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 6, $o), 0x6745);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 7, $o), 0x8967);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 8, $o), 0xAB89);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 9, $o), 0xCDAB);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 10, $o), 0xEFCD);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 11, $o), 0xFFEF);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 12, $o), 0xFFFF);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 13, $o), 0xFFFF);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 14, $o), 0xFFFF);
}
public function testShortBig()
{
$o = PelConvert::BIG_ENDIAN;
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 0, $o), 0x0000);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 1, $o), 0x0000);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 2, $o), 0x0000);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 3, $o), 0x0001);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 4, $o), 0x0123);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 5, $o), 0x2345);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 6, $o), 0x4567);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 7, $o), 0x6789);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 8, $o), 0x89AB);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 9, $o), 0xABCD);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 10, $o), 0xCDEF);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 11, $o), 0xEFFF);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 12, $o), 0xFFFF);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 13, $o), 0xFFFF);
$this->assertEquals(PelConvert::bytesToShort($this->bytes, 14, $o), 0xFFFF);
}
public function testSShortLittle()
{
$o = PelConvert::LITTLE_ENDIAN;
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 0, $o), 0);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 1, $o), 0);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 2, $o), 0);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 3, $o), 256);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 4, $o), 8961);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 5, $o), 17699);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 6, $o), 26437);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 7, $o), - 30361);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 8, $o), - 21623);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 9, $o), - 12885);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 10, $o), - 4147);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 11, $o), - 17);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 12, $o), - 1);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 13, $o), - 1);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 14, $o), - 1);
}
public function testSShortBig()
{
$o = PelConvert::BIG_ENDIAN;
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 0, $o), 0);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 1, $o), 0);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 2, $o), 0);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 3, $o), 1);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 4, $o), 291);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 5, $o), 9029);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 6, $o), 17767);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 7, $o), 26505);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 8, $o), - 30293);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 9, $o), - 21555);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 10, $o), - 12817);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 11, $o), - 4097);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 12, $o), - 1);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 13, $o), - 1);
$this->assertEquals(PelConvert::bytesToSShort($this->bytes, 14, $o), - 1);
}
public function testByte()
{
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 0), 0x00);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 1), 0x00);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 2), 0x00);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 3), 0x00);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 4), 0x01);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 5), 0x23);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 6), 0x45);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 7), 0x67);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 8), 0x89);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 9), 0xAB);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 10), 0xCD);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 11), 0xEF);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 12), 0xFF);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 13), 0xFF);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 14), 0xFF);
$this->assertEquals(PelConvert::bytesToByte($this->bytes, 15), 0xFF);
}
public function testSByte()
{
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 0), 0);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 1), 0);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 2), 0);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 3), 0);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 4), 1);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 5), 35);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 6), 69);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 7), 103);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 8), - 119);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 9), - 85);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 10), - 51);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 11), - 17);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 12), - 1);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 13), - 1);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 14), - 1);
$this->assertEquals(PelConvert::bytesToSByte($this->bytes, 15), - 1);
}
}

View File

@@ -0,0 +1,142 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelDataWindow;
use lsolesen\pel\PelConvert;
use lsolesen\pel\PelDataWindowOffsetException;
use PHPUnit\Framework\TestCase;
class DataWindowTest extends TestCase
{
public function testReadBytes()
{
$window = new PelDataWindow('abcdefgh');
$this->assertEquals($window->getSize(), 8);
$this->assertEquals($window->getBytes(), 'abcdefgh');
$this->assertEquals($window->getBytes(0), 'abcdefgh');
$this->assertEquals($window->getBytes(1), 'bcdefgh');
$this->assertEquals($window->getBytes(7), 'h');
// $this->assertEquals($window->getBytes(8), '');
$this->assertEquals($window->getBytes(- 1), 'h');
$this->assertEquals($window->getBytes(- 2), 'gh');
$this->assertEquals($window->getBytes(- 7), 'bcdefgh');
$this->assertEquals($window->getBytes(- 8), 'abcdefgh');
$clone = $window->getClone(2, 4);
$this->assertEquals($clone->getSize(), 4);
$this->assertEquals($clone->getBytes(), 'cdef');
$this->assertEquals($clone->getBytes(0), 'cdef');
$this->assertEquals($clone->getBytes(1), 'def');
$this->assertEquals($clone->getBytes(3), 'f');
// $this->assertEquals($clone->getBytes(4), '');
$this->assertEquals($clone->getBytes(- 1), 'f');
$this->assertEquals($clone->getBytes(- 2), 'ef');
$this->assertEquals($clone->getBytes(- 3), 'def');
$this->assertEquals($clone->getBytes(- 4), 'cdef');
$caught = false;
try {
$clone->getBytes(0, 6);
} catch (PelDataWindowOffsetException $e) {
$caught = true;
}
$this->assertTrue($caught);
}
public function testReadIntegers()
{
$window = new PelDataWindow("\x01\x02\x03\x04", PelConvert::BIG_ENDIAN);
$this->assertEquals($window->getSize(), 4);
$this->assertEquals($window->getBytes(), "\x01\x02\x03\x04");
$this->assertEquals($window->getByte(0), 0x01);
$this->assertEquals($window->getByte(1), 0x02);
$this->assertEquals($window->getByte(2), 0x03);
$this->assertEquals($window->getByte(3), 0x04);
$this->assertEquals($window->getShort(0), 0x0102);
$this->assertEquals($window->getShort(1), 0x0203);
$this->assertEquals($window->getShort(2), 0x0304);
$this->assertEquals($window->getLong(0), 0x01020304);
$window->setByteOrder(PelConvert::LITTLE_ENDIAN);
$this->assertEquals($window->getSize(), 4);
$this->assertEquals($window->getBytes(), "\x01\x02\x03\x04");
$this->assertEquals($window->getByte(0), 0x01);
$this->assertEquals($window->getByte(1), 0x02);
$this->assertEquals($window->getByte(2), 0x03);
$this->assertEquals($window->getByte(3), 0x04);
$this->assertEquals($window->getShort(0), 0x0201);
$this->assertEquals($window->getShort(1), 0x0302);
$this->assertEquals($window->getShort(2), 0x0403);
$this->assertEquals($window->getLong(0), 0x04030201);
}
public function testReadBigIntegers()
{
$window = new PelDataWindow("\x89\xAB\xCD\xEF", PelConvert::BIG_ENDIAN);
$this->assertEquals($window->getSize(), 4);
$this->assertEquals($window->getBytes(), "\x89\xAB\xCD\xEF");
$this->assertEquals($window->getByte(0), 0x89);
$this->assertEquals($window->getByte(1), 0xAB);
$this->assertEquals($window->getByte(2), 0xCD);
$this->assertEquals($window->getByte(3), 0xEF);
$this->assertEquals($window->getShort(0), 0x89AB);
$this->assertEquals($window->getShort(1), 0xABCD);
$this->assertEquals($window->getShort(2), 0xCDEF);
$this->assertEquals($window->getLong(0), 0x89ABCDEF);
$window->setByteOrder(PelConvert::LITTLE_ENDIAN);
$this->assertEquals($window->getSize(), 4);
$this->assertEquals($window->getBytes(), "\x89\xAB\xCD\xEF");
$this->assertEquals($window->getByte(0), 0x89);
$this->assertEquals($window->getByte(1), 0xAB);
$this->assertEquals($window->getByte(2), 0xCD);
$this->assertEquals($window->getByte(3), 0xEF);
$this->assertEquals($window->getShort(0), 0xAB89);
$this->assertEquals($window->getShort(1), 0xCDAB);
$this->assertEquals($window->getShort(2), 0xEFCD);
$this->assertEquals($window->getLong(0), 0xEFCDAB89);
}
}

View File

@@ -0,0 +1,89 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006, 2007 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelDataWindow;
use lsolesen\pel\PelEntryWindowsString;
use lsolesen\pel\PelExif;
use lsolesen\pel\PelIfd;
use lsolesen\pel\PelJpeg;
use lsolesen\pel\PelTag;
use lsolesen\pel\PelTiff;
class GH16Test extends TestCase
{
protected $file;
protected function setUp(): void
{
$this->file = dirname(__FILE__) . '/images/gh-16-tmp.jpg';
$file = dirname(__FILE__) . '/images/gh-16.jpg';
copy($file, $this->file);
}
public function tearDown(): void
{
unlink($this->file);
}
public function testThisDoesNotWorkAsExpected()
{
$subject = "Превед, медвед!";
$data = new PelDataWindow(file_get_contents($this->file));
if (PelJpeg::isValid($data)) {
$jpeg = new PelJpeg();
$jpeg->load($data);
$exif = $jpeg->getExif();
if (null === $exif) {
$exif = new PelExif();
$jpeg->setExif($exif);
$tiff = new PelTiff();
$exif->setTiff($tiff);
}
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
if (null === $ifd0) {
$ifd0 = new PelIfd(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
}
$ifd0->addEntry(new PelEntryWindowsString(PelTag::XP_SUBJECT, $subject));
file_put_contents($this->file, $jpeg->getBytes());
$jpeg = new PelJpeg($this->file);
$exif = $jpeg->getExif();
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
$written_subject = $ifd0->getEntry(PelTag::XP_SUBJECT);
$this->assertEquals($subject, $written_subject->getValue());
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006, 2007 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class GH21Test extends TestCase
{
protected $file;
public function setUp(): void
{
$this->file = dirname(__FILE__) . '/images/gh-21-tmp.jpg';
$file = dirname(__FILE__) . '/images/gh-21.jpg';
copy($file, $this->file);
}
public function tearDown(): void
{
unlink($this->file);
}
public function testThisDoesNotWorkAsExpected()
{
$scale = 0.75;
$input_jpeg = new PelJpeg($this->file);
$original = ImageCreateFromString($input_jpeg->getBytes());
$this->assertNotFalse($original, 'New image must not be false');
$original_w = ImagesX($original);
$original_h = ImagesY($original);
$scaled_w = (int) ($original_w * $scale);
$scaled_h = (int) ($original_h * $scale);
$scaled = ImageCreateTrueColor($scaled_w, $scaled_h);
$this->assertNotFalse($scaled, 'Resized image must not be false');
ImageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h);
$output_jpeg = new PelJpeg($scaled);
$exif = $input_jpeg->getExif();
if ($exif !== null) {
$output_jpeg->setExif($exif);
}
file_put_contents($this->file, $output_jpeg->getBytes());
$jpeg = new PelJpeg($this->file);
$exifin = $jpeg->getExif();
$this->assertEquals($exif, $exifin);
}
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006, 2007 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelJpeg;
use lsolesen\pel\PelTag;
class GH77Test extends TestCase
{
public function testReturnModul()
{
$file = dirname(__FILE__) . '/images/gh-77.jpg';
$input_jpeg = new PelJpeg($file);
$app1 = $input_jpeg->getExif();
$tiff = $app1->getTiff();
$ifd0 = $tiff->getIfd();
$model = $ifd0->getEntry(PelTag::MODEL);
$this->assertEquals($model->getValue(), "Canon EOS 5D Mark III");
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelEntryAscii;
use lsolesen\pel\PelEntryTime;
use lsolesen\pel\PelIfd;
use lsolesen\pel\PelTag;
class IfdTest extends TestCase
{
public function testIteratorAggretate()
{
$ifd = new PelIfd(PelIfd::IFD0);
$this->assertEquals(sizeof($ifd->getIterator()), 0);
$desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, 'Hello?');
$date = new PelEntryTime(PelTag::DATE_TIME, 12345678);
$ifd->addEntry($desc);
$ifd->addEntry($date);
$this->assertEquals(sizeof($ifd->getIterator()), 2);
$entries = [];
foreach ($ifd as $tag => $entry) {
$entries[$tag] = $entry;
}
$this->assertSame($entries[PelTag::IMAGE_DESCRIPTION], $desc);
$this->assertSame($entries[PelTag::DATE_TIME], $date);
}
public function testArrayAccess()
{
$ifd = new PelIfd(PelIfd::IFD0);
$this->assertEquals(sizeof($ifd->getIterator()), 0);
$desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, 'Hello?');
$date = new PelEntryTime(PelTag::DATE_TIME, 12345678);
$ifd[] = $desc;
$ifd[] = $date;
$this->assertSame($ifd[PelTag::IMAGE_DESCRIPTION], $desc);
$this->assertSame($ifd[PelTag::DATE_TIME], $date);
unset($ifd[PelTag::DATE_TIME]);
$this->assertFalse(isset($ifd[PelTag::DATE_TIME]));
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006, 2007 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelException;
use lsolesen\pel\PelJpeg;
class LoadNonExistingJpegTest extends TestCase
{
public function testWindowWindowExceptionIsCaught()
{
$this->expectException(PelException::class);
new PelJpeg('non-existing-file');
}
}

View File

@@ -0,0 +1,82 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\Pel;
use lsolesen\pel\PelExif;
use lsolesen\pel\PelJpeg;
use lsolesen\pel\PelJpegMarker;
class MisplacedExifTest extends TestCase
{
// NOTE: this test relies on the assumption that internal PelJpeg::sections order is kept between section
// manipulations. It may fail it this changes.
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
// Image contains non-EXIF APP1 section ahead of the EXIF one
$jpeg = new PelJpeg(dirname(__FILE__) . '/broken_images/misplaced-exif.jpg');
// Assert we just have loaded correct file for the test
$this->assertNotInstanceOf('\lsolesen\pel\PelExif', $jpeg->getSection(PelJpegMarker::APP1));
// Manually find exif APP1 section index
$sections1 = $jpeg->getSections();
$exifIdx = null;
$idx = 0;
foreach ($sections1 as $section) {
if (($section[0] == PelJpegMarker::APP1) && ($section[1] instanceof PelExif)) {
$exifIdx = $idx;
break;
}
++ $idx;
}
$this->assertNotNull($exifIdx);
$newExif = new PelExif();
$jpeg->setExif($newExif);
// Ensure EXIF is set to correct position among sections
$sections2 = $jpeg->getSections();
$this->assertSame($sections1[$exifIdx][0], $sections2[$exifIdx][0]);
$this->assertNotSame($sections1[$exifIdx][1], $sections2[$exifIdx][1]);
$this->assertSame($newExif, $sections2[$exifIdx][1]);
$this->assertInstanceOf('\lsolesen\pel\PelExif', $jpeg->getExif());
$jpeg->clearExif();
// Assert that only EXIF section is gone and all other shifted correctly.
$sections3 = $jpeg->getSections();
$numSections3 = count($sections3);
for ($idx = 0; $idx < $numSections3; ++ $idx) {
if ($idx >= $exifIdx) {
$s2idx = $idx + 1;
} else {
$s2idx = $idx;
}
$this->assertSame($sections2[$s2idx][0], $sections3[$idx][0]);
$this->assertSame($sections2[$s2idx][1], $sections3[$idx][1]);
}
$this->assertNotInstanceOf('\lsolesen\pel\PelExif', $jpeg->getExif());
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
class NoExifTest extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/images/no-exif.jpg');
$exif = $jpeg->getExif();
$this->assertNull($exif);
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelEntryByte;
class NumberByteTest extends NumberTestCase
{
/**
*
* {@inheritdoc}
*/
public function setUp(): void
{
parent::setUp();
$this->num = new PelEntryByte(42);
$this->min = 0;
$this->max = 255;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelEntryLong;
class NumberLongTest extends NumberTestCase
{
/**
*
* {@inheritdoc}
*/
public function setUp(): void
{
parent::setUp();
$this->num = new PelEntryLong(42);
$this->min = 0;
$this->max = 4294967295;
}
}

View File

@@ -0,0 +1,154 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelEntryRational;
use lsolesen\pel\PelOverflowException;
class NumberRationalTest extends NumberTestCase
{
public function testOverflow()
{
$entry = new PelEntryRational(42, [
1,
2
]);
$this->assertEquals($entry->getValue(), [
1,
2
]);
$caught = false;
try {
$entry->setValue([
3,
4
], [
- 1,
2
], [
7,
8
]);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertEquals($entry->getValue(), [
1,
2
]);
$caught = false;
try {
$entry->setValue([
3,
4
], [
1,
4294967296
]);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertEquals($entry->getValue(), [
1,
2
]);
$caught = false;
try {
$entry->setValue([
3,
4
], [
4294967296,
1
]);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertEquals($entry->getValue(), [
1,
2
]);
}
public function testReturnValues()
{
$entry = new PelEntryRational(42);
$this->assertEquals($entry->getValue(), []);
$this->assertEquals($entry->getText(), '');
$entry->setValue([
1,
2
], [
3,
4
], [
5,
6
]);
$this->assertEquals($entry->getValue(), [
[
1,
2
],
[
3,
4
],
[
5,
6
]
]);
$this->assertEquals($entry->getText(), '1/2, 3/4, 5/6');
$entry->setValue([
7,
8
]);
$this->assertEquals($entry->getValue(), [
7,
8
]);
$this->assertEquals($entry->getText(), '7/8');
$entry->setValue([
0,
4294967295
]);
$this->assertEquals($entry->getValue(), [
0,
4294967295
]);
$this->assertEquals($entry->getText(), '0/4294967295');
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelEntrySByte;
class NumberSByteTest extends NumberTestCase
{
public function setUp(): void
{
parent::setUp();
$this->num = new PelEntrySByte(42);
$this->min = - 128;
$this->max = 127;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelEntrySLong;
class NumberSLongTest extends NumberTestCase
{
public function setUp(): void
{
parent::setUp();
$this->num = new PelEntrySLong(42);
$this->min = - 2147483648;
$this->max = 2147483647;
}
}

View File

@@ -0,0 +1,150 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelEntrySRational;
use lsolesen\pel\PelOverflowException;
class NumberSRationalTest extends NumberTestCase
{
public function testOverflow()
{
$entry = new PelEntrySRational(42, [
- 1,
2
]);
$this->assertEquals($entry->getValue(), [
- 1,
2
]);
$caught = false;
try {
$entry->setValue([
- 10,
- 20
], [
- 1,
- 2147483649
]);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertEquals($entry->getValue(), [
- 1,
2
]);
$caught = false;
try {
$entry->setValue([
3,
4
], [
1,
2147483648
]);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertEquals($entry->getValue(), [
- 1,
2
]);
$caught = false;
try {
$entry->setValue([
3,
4
], [
4294967296,
1
]);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertEquals($entry->getValue(), [
- 1,
2
]);
}
public function testReturnValues()
{
$entry = new PelEntrySRational(42);
$this->assertEquals($entry->getValue(), []);
$entry->setValue([
- 1,
2
], [
3,
4
], [
5,
- 6
]);
$this->assertEquals($entry->getValue(), [
[
- 1,
2
],
[
3,
4
],
[
5,
- 6
]
]);
$this->assertEquals($entry->getText(), '-1/2, 3/4, -5/6');
$entry->setValue([
- 7,
- 8
]);
$this->assertEquals($entry->getValue(), [
- 7,
- 8
]);
$this->assertEquals($entry->getText(), '7/8');
$entry->setValue([
0,
2147483647
]);
$this->assertEquals($entry->getValue(), [
0,
2147483647
]);
$this->assertEquals($entry->getText(), '0/2147483647');
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelEntrySShort;
class NumberSShortTest extends NumberTestCase
{
public function setUp(): void
{
parent::setUp();
$this->num = new PelEntrySShort(42);
$this->min = - 32768;
$this->max = 32767;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\PelEntryShort;
class NumberShortTest extends NumberTestCase
{
/**
*
* {@inheritdoc}
*/
public function setUp(): void
{
parent::setUp();
$this->num = new PelEntryShort(42);
$this->min = 0;
$this->max = 65535;
}
}

View File

@@ -0,0 +1,114 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\Pel;
use lsolesen\pel\PelOverflowException;
abstract class NumberTestCase extends TestCase
{
protected $min;
protected $max;
protected $num;
/**
*
* {@inheritdoc}
*/
public function setUp(): void
{
parent::setUp();
Pel::setStrictParsing(true);
}
public function testOverflow()
{
$this->num->setValue(0);
$this->assertSame(0, $this->num->getValue());
$caught = false;
try {
$this->num->setValue($this->min - 1);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertSame(0, $this->num->getValue());
$caught = false;
try {
$this->num->setValue($this->max + 1);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertSame(0, $this->num->getValue());
$caught = false;
try {
$this->num->setValue(0, $this->max + 1);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertSame(0, $this->num->getValue());
$caught = false;
try {
$this->num->setValue(0, $this->min - 1);
} catch (PelOverflowException $e) {
$caught = true;
}
$this->assertTrue($caught);
$this->assertSame(0, $this->num->getValue());
}
public function testReturnValues()
{
$this->num->setValue(1, 2, 3);
$this->assertSame([
1,
2,
3
], $this->num->getValue());
$this->assertSame('1, 2, 3', $this->num->getText());
$this->num->setValue(1);
$this->assertSame(1, $this->num->getValue());
$this->assertSame(1, $this->num->getText());
$this->num->setValue($this->max);
$this->assertSame($this->max, $this->num->getValue());
$this->assertSame($this->max, $this->num->getText());
$this->num->setValue($this->min);
$this->assertSame($this->min, $this->num->getValue());
$this->assertSame($this->min, $this->num->getText());
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006 Martin Geisler.
* Copyright (C) 2017 Johannes Weberhofer
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelConvert;
use lsolesen\pel\PelEntryUndefined;
use lsolesen\pel\PelEntryUserComment;
use lsolesen\pel\PelEntryVersion;
class PelEntryUndefinedTest extends TestCase
{
public function testReturnValues()
{
new PelEntryUndefined(42);
$entry = new PelEntryUndefined(42, 'foo bar baz');
$this->assertEquals($entry->getComponents(), 11);
$this->assertEquals($entry->getValue(), 'foo bar baz');
}
public function testUsercomment()
{
$entry = new PelEntryUserComment();
$this->assertEquals($entry->getComponents(), 8);
$this->assertEquals($entry->getValue(), '');
$this->assertEquals($entry->getEncoding(), 'ASCII');
$entry->setValue('Hello!');
$this->assertEquals($entry->getComponents(), 14);
$this->assertEquals($entry->getValue(), 'Hello!');
$this->assertEquals($entry->getEncoding(), 'ASCII');
}
public function testVersion()
{
$entry = new PelEntryVersion(42);
$this->assertEquals($entry->getValue(), 0.0);
$entry->setValue(2.0);
$this->assertEquals($entry->getValue(), 2.0);
$this->assertEquals($entry->getText(false), 'Version 2.0');
$this->assertEquals($entry->getText(true), '2.0');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0200');
$entry->setValue(2.1);
$this->assertEquals($entry->getValue(), 2.1);
$this->assertEquals($entry->getText(false), 'Version 2.1');
$this->assertEquals($entry->getText(true), '2.1');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0210');
$entry->setValue(2.01);
$this->assertEquals($entry->getValue(), 2.01);
$this->assertEquals($entry->getText(false), 'Version 2.01');
$this->assertEquals($entry->getText(true), '2.01');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0201');
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006 Martin Geisler.
* Copyright (C) 2017 Johannes Weberhofer
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelEntryUserComment;
class PelEntryUserCommentTest extends TestCase
{
public function testUsercomment()
{
$entry = new PelEntryUserComment();
$this->assertEquals($entry->getComponents(), 8);
$this->assertEquals($entry->getValue(), '');
$this->assertEquals($entry->getEncoding(), 'ASCII');
$entry->setValue('Hello!');
$this->assertEquals($entry->getComponents(), 14);
$this->assertEquals($entry->getValue(), 'Hello!');
$this->assertEquals($entry->getEncoding(), 'ASCII');
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006 Martin Geisler.
* Copyright (C) 2017 Johannes Weberhofer
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelConvert;
use lsolesen\pel\PelEntryVersion;
class PelEntryVersionTest extends TestCase
{
public function testVersion()
{
$entry = new PelEntryVersion(42);
$this->assertEquals($entry->getValue(), 0.0);
$entry->setValue(2.0);
$this->assertEquals($entry->getValue(), 2.0);
$this->assertEquals($entry->getText(false), 'Version 2.0');
$this->assertEquals($entry->getText(true), '2.0');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0200');
$entry->setValue(2.1);
$this->assertEquals($entry->getValue(), 2.1);
$this->assertEquals($entry->getText(false), 'Version 2.1');
$this->assertEquals($entry->getText(true), '2.1');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0210');
$entry->setValue(2.01);
$this->assertEquals($entry->getValue(), 2.01);
$this->assertEquals($entry->getText(false), 'Version 2.01');
$this->assertEquals($entry->getText(true), '2.01');
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0201');
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006 Martin Geisler.
* Copyright (C) 2017 Johannes Weberhofer
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelConvert;
use lsolesen\pel\PelEntryWindowsString;
use lsolesen\pel\PelTag;
class PelEntryWindowsStringTest extends TestCase
{
public function testWindowsString()
{
$test_str = 'Tést';
$test_str_ucs2 = mb_convert_encoding($test_str, 'UCS-2LE', 'auto');
$test_str_ucs2_zt = $test_str_ucs2 . PelEntryWindowsString::ZEROES;
$entry = new PelEntryWindowsString(PelTag::XP_TITLE, $test_str);
$this->assertNotEquals($entry->getValue(), $entry->getBytes(PelConvert::LITTLE_ENDIAN));
$this->assertEquals($entry->getValue(), $test_str);
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), $test_str_ucs2_zt);
// correct zero-terminated data from the exif
$entry->setValue($test_str_ucs2_zt, true);
$this->assertNotEquals($entry->getValue(), $entry->getBytes(PelConvert::LITTLE_ENDIAN));
$this->assertEquals($entry->getValue(), $test_str);
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), $test_str_ucs2_zt);
// incorrect data from exif
$entry->setValue($test_str_ucs2, true);
$this->assertNotEquals($entry->getValue(), $entry->getBytes(PelConvert::LITTLE_ENDIAN));
$this->assertEquals($entry->getValue(), $test_str);
$this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), $test_str_ucs2_zt);
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006 Martin Geisler.
* Copyright (C) 2017 Johannes Weberhofer
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelFormat;
use lsolesen\pel\PelIllegalFormatException;
class PelFormatTest extends TestCase
{
public function testNames()
{
$pelFormat = new PelFormat();
$this->assertEquals($pelFormat::getName(PelFormat::ASCII), 'Ascii');
$this->assertEquals($pelFormat::getName(PelFormat::FLOAT), 'Float');
$this->assertEquals($pelFormat::getName(PelFormat::UNDEFINED), 'Undefined');
$this->expectException(PelIllegalFormatException::class);
$pelFormat::getName(100);
}
public function testDescriptions()
{
$pelFormat = new PelFormat();
$this->assertEquals($pelFormat::getSize(PelFormat::ASCII), 1);
$this->assertEquals($pelFormat::getSize(PelFormat::FLOAT), 4);
$this->assertEquals($pelFormat::getSize(PelFormat::UNDEFINED), 1);
$this->expectException(PelIllegalFormatException::class);
$pelFormat::getSize(100);
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006 Martin Geisler.
* Copyright (C) 2017 Johannes Weberhofer
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpegInvalidMarkerException;
use lsolesen\pel\PelJpegMarker;
class PelJpegMarkerTest extends TestCase
{
public function testNames()
{
$jpegMarker = new PelJpegMarker();
$this->assertEquals($jpegMarker::getName(PelJpegMarker::SOF0), 'SOF0');
$this->assertEquals($jpegMarker::getName(PelJpegMarker::RST3), 'RST3');
$this->assertEquals($jpegMarker::getName(PelJpegMarker::APP3), 'APP3');
$this->assertEquals($jpegMarker::getName(PelJpegMarker::JPG11), 'JPG11');
$this->assertEquals($jpegMarker::getName(100), Pel::fmt('Unknown marker: 0x%02X', 100));
}
public function testDescriptions()
{
$jpegMarker = new PelJpegMarker();
$this->assertEquals($jpegMarker::getDescription(PelJpegMarker::SOF0), 'Encoding (baseline)');
$this->assertEquals($jpegMarker::getDescription(PelJpegMarker::RST3), Pel::fmt('Restart %d', 3));
$this->assertEquals($jpegMarker::getDescription(PelJpegMarker::APP3), Pel::fmt('Application segment %d', 3));
$this->assertEquals($jpegMarker::getDescription(PelJpegMarker::JPG11), Pel::fmt('Extension %d', 11));
$this->assertEquals($jpegMarker::getDescription(100), Pel::fmt('Unknown marker: 0x%02X', 100));
}
/**
*
* @throws PelJpegInvalidMarkerException
*/
public function testInvalidMarkerException()
{
$this->expectException('lsolesen\pel\PelJpegInvalidMarkerException');
throw new PelJpegInvalidMarkerException(1, 2);
}
}

View File

@@ -0,0 +1,61 @@
<?php
/**
* PEL: PHP Exif Library.
* A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006 Martin Geisler.
* Copyright (C) 2017 Johannes Weberhofer
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\PelIfd;
use lsolesen\pel\PelTag;
class PelTagTest extends TestCase
{
const NONEXISTENT_TAG_NAME = 'nonexistent tag name';
const NONEXISTENT_EXIF_TAG = 0xFCFC;
const NONEXISTENT_GPS_TAG = 0xFCFC;
const EXIF_TAG_NAME = 'ImageDescription';
const GPS_TAG_NAME = 'GPSLongitude';
const EXIF_TAG = PelTag::IMAGE_DESCRIPTION;
const GPS_TAG = PelTag::GPS_LONGITUDE;
public function testReverseLookup()
{
$this->assertSame(false, PelTag::getExifTagByName(self::NONEXISTENT_TAG_NAME), 'Non-existent EXIF tag name');
$this->assertSame(false, PelTag::getGpsTagByName(self::NONEXISTENT_TAG_NAME), 'Non-existent GPS tag name');
$this->assertStringStartsWith('Unknown: ', PelTag::getName(PelIfd::IFD0, self::NONEXISTENT_EXIF_TAG), 'Non-existent EXIF tag');
$this->assertStringStartsWith('Unknown: ', PelTag::getName(PelIfd::GPS, self::NONEXISTENT_GPS_TAG), 'Non-existent GPS tag');
$this->assertSame(static::EXIF_TAG, PelTag::getExifTagByName(self::EXIF_TAG_NAME), 'EXIF tag name');
$this->assertSame(static::GPS_TAG, PelTag::getGpsTagByName(self::GPS_TAG_NAME), 'GPS tag name');
$this->assertEquals(static::EXIF_TAG_NAME, PelTag::getName(PelIfd::IFD0, self::EXIF_TAG), 'EXIF tag');
$this->assertEquals(static::GPS_TAG_NAME, PelTag::getName(PelIfd::GPS, self::GPS_TAG), 'GPS tag');
}
}

View File

@@ -0,0 +1,45 @@
# README file for PEL Test Suite
The tests run automatically on each commit on TravisCI. Status for the
master branch is:
[![Build Status](https://secure.travis-ci.org/pel/pel.png?branch=master)](http://travis-ci.org/pel/pel)
## PEL Test Suite
This directory holds the PHPUnit test suite for PEL. The test
suite consists of a number of core tests which exercise the basic
functionality of PEL.
In addition to the core tests, one can download a set of image tests.
These consist of example images taken from as many different camera
models as possible together with a test case that will ensure that PEL
can read the data in the image, and that it keeps interpreting the
data in the same way. This ensures stability in the development
process by making sure that PEL keeps reading images in the same way.
## Running the Test Suite
First the make sure PHPUnit is downloaded. You can do so in
the project's top directory via composer
```bash
composer update
```
Now from the top of the project, you can run
```bash
phpunit
```
## Failing Tests
Should one or more of the tests fail, please report the error to
the PEL developers:
https://github.com/pel/pel/issues
Remember to include all the output in your bug report.

View File

@@ -0,0 +1,263 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2004, 2006, 2007 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use lsolesen\pel\Pel;
use lsolesen\pel\PelEntryByte;
use lsolesen\pel\PelIfd;
use lsolesen\pel\PelTag;
use lsolesen\pel\PelTiff;
use lsolesen\pel\PelExif;
use lsolesen\pel\PelJpeg;
use lsolesen\pel\PelFormat;
use lsolesen\pel\PelEntrySByte;
use lsolesen\pel\PelEntryShort;
use lsolesen\pel\PelEntrySShort;
use lsolesen\pel\PelEntryLong;
use lsolesen\pel\PelEntrySLong;
use lsolesen\pel\PelEntryAscii;
use PHPUnit\Framework\TestCase;
class ReadWriteTest extends TestCase
{
/**
*
* {@inheritdoc}
*/
public function setUp(): void
{
parent::setUp();
Pel::setStrictParsing(true);
}
/**
*
* @dataProvider writeEntryProvider
*/
public function testWriteRead(array $entries)
{
$ifd = new PelIfd(PelIfd::IFD0);
$this->assertTrue($ifd->isLastIfd());
foreach ($entries as $entry) {
$ifd->addEntry($entry);
}
$tiff = new PelTiff();
$this->assertNull($tiff->getIfd());
$tiff->setIfd($ifd);
$this->assertNotNull($tiff->getIfd());
$exif = new PelExif();
$this->assertNull($exif->getTiff());
$exif->setTiff($tiff);
$this->assertNotNull($exif->getTiff());
$jpeg = new PelJpeg(dirname(__FILE__) . '/images/no-exif.jpg');
$this->assertNull($jpeg->getExif());
$jpeg->setExif($exif);
$this->assertNotNull($jpeg->getExif());
$jpeg->saveFile('test-output.jpg');
$this->assertTrue(file_exists('test-output.jpg'));
$this->assertTrue(filesize('test-output.jpg') > 0);
/* Now read the file and see if the entries are still there. */
$jpeg = new PelJpeg('test-output.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
$ifd = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd);
$this->assertEquals($ifd->getType(), PelIfd::IFD0);
$this->assertTrue($ifd->isLastIfd());
foreach ($entries as $entry) {
$ifdEntry = $ifd->getEntry($entry->getTag());
if ($ifdEntry->getFormat() == PelFormat::ASCII) {
$ifdValue = $ifd->getEntry($entry->getTag())
->getValue();
$entryValue = $entry->getValue();
// cut off after the first nul byte
// since $ifdValue comes from parsed ifd,
// it is already cut off
$canonicalEntry = strstr($entryValue, "\0", true);
// if no nul byte found, use original value
if ($canonicalEntry === false) {
$canonicalEntry = $entryValue;
}
$this->assertEquals($ifdValue, $canonicalEntry);
} else {
$this->assertEquals($ifdEntry->getValue(), $entry->getValue());
}
}
unlink('test-output.jpg');
}
public function writeEntryProvider()
{
return [
'PEL Byte Read/Write Tests' => [
[
new PelEntryByte(0xF001, 0),
new PelEntryByte(0xF002, 1),
new PelEntryByte(0xF003, 2),
new PelEntryByte(0xF004, 253),
new PelEntryByte(0xF005, 254),
new PelEntryByte(0xF006, 255),
new PelEntryByte(0xF007, 0, 1, 2, 253, 254, 255),
new PelEntryByte(0xF008)
]
],
'PEL SByte Read/Write Tests' => [
[
new PelEntrySByte(0xF101, - 128),
new PelEntrySByte(0xF102, - 127),
new PelEntrySByte(0xF103, - 1),
new PelEntrySByte(0xF104, 0),
new PelEntrySByte(0xF105, 1),
new PelEntrySByte(0xF106, 126),
new PelEntrySByte(0xF107, 127),
new PelEntrySByte(0xF108, - 128, - 1, 0, 1, 127),
new PelEntrySByte(0xF109)
]
],
'PEL Short Read/Write Tests' => [
[
new PelEntryShort(0xF201, 0),
new PelEntryShort(0xF202, 1),
new PelEntryShort(0xF203, 2),
new PelEntryShort(0xF204, 65533),
new PelEntryShort(0xF205, 65534),
new PelEntryShort(0xF206, 65535),
new PelEntryShort(0xF208, 0, 1, 65534, 65535),
new PelEntryShort(0xF209)
]
],
'PEL SShort Read/Write Tests' => [
[
new PelEntrySShort(0xF301, - 32768),
new PelEntrySShort(0xF302, - 32767),
new PelEntrySShort(0xF303, - 1),
new PelEntrySShort(0xF304, 0),
new PelEntrySShort(0xF305, 1),
new PelEntrySShort(0xF306, 32766),
new PelEntrySShort(0xF307, 32767),
new PelEntrySShort(0xF308, - 32768, - 1, 0, 1, 32767),
new PelEntrySShort(0xF309)
]
],
'PEL Long Read/Write Tests' => [
[
new PelEntryLong(0xF401, 0),
new PelEntryLong(0xF402, 1),
new PelEntryLong(0xF403, 2),
new PelEntryLong(0xF404, 4294967293),
new PelEntryLong(0xF405, 4294967294),
new PelEntryLong(0xF406, 4294967295),
new PelEntryLong(0xF408, 0, 1, 4294967295),
new PelEntryLong(0xF409)
]
],
'PEL SLong Read/Write Tests' => [
[
new PelEntrySLong(0xF501, - 2147483648),
new PelEntrySLong(0xF502, - 2147483647),
new PelEntrySLong(0xF503, - 1),
new PelEntrySLong(0xF504, 0),
new PelEntrySLong(0xF505, 1),
new PelEntrySLong(0xF506, 2147483646),
new PelEntrySLong(0xF507, 2147483647),
new PelEntrySLong(0xF508, - 2147483648, 0, 2147483647),
new PelEntrySLong(0xF509)
]
],
'PEL Ascii Read/Write Tests' => [
[
new PelEntryAscii(0xF601),
new PelEntryAscii(0xF602, ''),
new PelEntryAscii(0xF603, 'Hello World!'),
new PelEntryAscii(0xF604, "\x00\x01\x02...\xFD\xFE\xFF")
]
]
];
}
/**
* Tests loading and writing back a TIFF image file.
*/
public function testTiffLoadSave()
{
$file_uri = dirname(__FILE__) . '/images/sample-1.tiff';
$data = @exif_read_data($file_uri);
$this->assertEquals(1, $data['Orientation']);
$this->assertEquals(2, $data['PhotometricInterpretation']);
$tiff = new PelTiff($file_uri);
$ifd = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd);
$orientation = $ifd->getEntry(PelTag::ORIENTATION);
$this->assertEquals(1, $orientation->getValue());
$photometric_interpretation = $ifd->getEntry(PelTag::PHOTOMETRIC_INTERPRETATION);
$this->assertEquals(2, $photometric_interpretation->getValue());
$bits_per_sample = $ifd->getEntry(PelTag::BITS_PER_SAMPLE);
$this->assertEquals([
8,
8,
8,
8
], $bits_per_sample->getValue());
$orientation->setValue(4);
$photometric_interpretation->setValue(4);
$bits_per_sample->setValueArray([
7,
6,
5,
4
]);
$out_uri = dirname(__FILE__) . '/images/output.sample-1.tiff';
$tiff->saveFile($out_uri);
$data_reload = @exif_read_data($out_uri);
$this->assertEquals(4, $data_reload['Orientation']);
$this->assertEquals(4, $data_reload['PhotometricInterpretation']);
$this->assertEquals([
7,
6,
5,
4
], $data_reload['BitsPerSample']);
unlink($out_uri);
}
}

View File

@@ -0,0 +1,67 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
class Tags1Test extends TestCase
{
public function testTags()
{
Pel::clearExceptions();
Pel::setStrictParsing(true);
$jpeg = new PelJpeg(dirname(__FILE__) . '/images/test-tags-1.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('\lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('\lsolesen\pel\PelTiff', $tiff);
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('\lsolesen\pel\PelIfd', $ifd0);
$ratingPercent = $ifd0->getEntry(\lsolesen\pel\PelTag::RATING_PERCENT);
$this->assertInstanceOf('\lsolesen\pel\PelEntry', $ratingPercent);
$this->assertEquals(78, $ratingPercent->getValue());
$exifIfd = $ifd0->getSubIfd(\lsolesen\pel\PelIfd::EXIF);
$this->assertInstanceOf('\lsolesen\pel\PelIfd', $exifIfd);
$offsetTime = $exifIfd->getEntry(\lsolesen\pel\PelTag::OFFSET_TIME);
$this->assertInstanceOf('\lsolesen\pel\PelEntry', $offsetTime);
$this->assertEquals('-09:00', $offsetTime->getValue());
$offsetTimeDigitized = $exifIfd->getEntry(\lsolesen\pel\PelTag::OFFSET_TIME_DIGITIZED);
$this->assertInstanceOf('\lsolesen\pel\PelEntry', $offsetTimeDigitized);
$this->assertEquals('-10:00', $offsetTimeDigitized->getValue());
$offsetTimeOriginal = $exifIfd->getEntry(\lsolesen\pel\PelTag::OFFSET_TIME_ORIGINAL);
$this->assertInstanceOf('\lsolesen\pel\PelEntry', $offsetTimeOriginal);
$this->assertEquals('-11:00', $offsetTimeOriginal->getValue());
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@@ -0,0 +1,335 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use PHPUnit\Framework\TestCase;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
class CanonEos650dTest extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/canon-eos-650d.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(9, count($ifd0->getEntries()));
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals('Canon', $entry->getValue());
$this->assertEquals('Canon', $entry->getText());
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals('Canon EOS 650D', $entry->getValue());
$this->assertEquals('Canon EOS 650D', $entry->getText());
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(1, $entry->getValue());
$this->assertEquals('top - left', $entry->getText());
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals([
0 => 72,
1 => 1
], $entry->getValue());
$this->assertEquals('72/1', $entry->getText());
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals([
0 => 72,
1 => 1
], $entry->getValue());
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(2, $entry->getValue());
$this->assertEquals('Inch', $entry->getText());
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals(1509974253, $entry->getValue());
$this->assertEquals('2017:11:06 13:17:33', $entry->getText());
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 2);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 29);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals([
0 => 1,
1 => 800
], $entry->getValue());
$this->assertEquals('1/800 sec.', $entry->getText());
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals([
0 => 63,
1 => 10
], $entry->getValue());
$this->assertEquals('f/6.3', $entry->getText());
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals(2.3, $entry->getValue());
$this->assertEquals('Exif Version 2.3', $entry->getText());
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals(1497623444, $entry->getValue());
$this->assertEquals('2017:06:16 14:30:44', $entry->getText());
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals(1497623444, $entry->getValue());
$this->assertEquals('2017:06:16 14:30:44', $entry->getText());
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals("\x01\x02\x03\0", $entry->getValue());
$this->assertEquals('Y Cb Cr -', $entry->getText());
$entry = $ifd0_0->getEntry(37378); // ApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 352256,
1 => 65536
]);
$this->assertEquals($entry->getText(), 'f/6.4');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals([
0 => 0,
1 => 1
], $entry->getValue());
$this->assertEquals('0.0', $entry->getText());
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(5, $entry->getValue());
$this->assertEquals('Pattern', $entry->getText());
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(16, $entry->getValue());
$this->assertEquals('Flash did not fire, compulsory flash mode.', $entry->getText());
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals([
0 => 600,
1 => 1
], $entry->getValue());
$this->assertEquals('600.0 mm', $entry->getText());
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertNull($entry);
$entry = $ifd0_0->getEntry(37510); // UserComment
$this->assertInstanceOf('lsolesen\pel\PelEntryUserComment', $entry);
$expected = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($expected, $entry->getValue());
$expected = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($expected, $entry->getText());
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals(1, $entry->getValue());
$this->assertEquals('FlashPix Version 1.0', $entry->getText());
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(1, $entry->getValue());
$this->assertEquals('sRGB', $entry->getText());
$entry = $ifd0_0->getEntry(41488); // FocalPlaneResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(2, $entry->getValue());
$this->assertEquals('Inch', $entry->getText());
$entry = $ifd0_0->getEntry(41985); // CustomRendered
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(0, $entry->getValue());
$this->assertEquals('Normal process', $entry->getText());
$entry = $ifd0_0->getEntry(41986); // ExposureMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(0, $entry->getValue());
$this->assertEquals('Auto exposure', $entry->getText());
$entry = $ifd0_0->getEntry(41987); // WhiteBalance
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(0, $entry->getValue());
$this->assertEquals('Auto white balance', $entry->getText());
$entry = $ifd0_0->getEntry(41990); // SceneCaptureType
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(0, $entry->getValue(), 0);
$this->assertEquals('Standard', $entry->getText());
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 2);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(2, count($ifd0_0_0->getEntries()));
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals('R98', $entry->getValue());
$this->assertEquals('R98', $entry->getText());
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals(1, $entry->getValue());
$this->assertEquals('Interoperability Version 1.0', $entry->getText());
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(0, count($ifd0_0_0->getSubIfds()));
$this->assertEquals('', $ifd0_0_0->getThumbnailData());
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals('', $ifd0_0->getThumbnailData());
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals('', $ifd0->getThumbnailData());
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 4);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(0, $entry->getValue());
$this->assertEquals('0', $entry->getText());
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals([
0 => 72,
1 => 1
], $entry->getValue());
$this->assertEquals('72/1', $entry->getText());
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals([
0 => 72,
1 => 1
], $entry->getValue());
$this->assertEquals('72/1', $entry->getText());
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals(2, $entry->getValue());
$this->assertEquals('Inch', $entry->getText());
/* Sub IFDs of $ifd1. */
$this->assertEquals(0, count($ifd1->getSubIfds()));
$thumb_data = file_get_contents(dirname(__FILE__) . '/canon-eos-650d-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
/* Start of IDF $ifd0_mn */
$ifd0_mn = $ifd0_0->getSubIfd(5); // IFD MakerNotes
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_mn);
$entry = $ifd0_mn->getEntry(6); // ImageType
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals('Canon EOS 650D', $entry->getValue());
$entry = $ifd0_mn->getEntry(7); // FirmwareVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals('Firmware Version 1.0.4', $entry->getValue());
/* Start of IDF $ifd0_mn_cs. */
$ifd0_mn_cs = $ifd0_mn->getSubIfd(6); // CameraSettings
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_mn_cs);
$this->assertEquals(37, count($ifd0_mn_cs->getEntries()));
$entry = $ifd0_mn_cs->getEntry(1); // MacroMode
$this->assertInstanceOf('lsolesen\pel\PelEntrySShort', $entry);
$this->assertEquals('2', $entry->getValue());
$this->assertEquals('Normal', $entry->getText());
$entry = $ifd0_mn_cs->getEntry(9); // RecordMode
$this->assertInstanceOf('lsolesen\pel\PelEntrySShort', $entry);
$this->assertEquals('6', $entry->getValue());
$this->assertEquals('CR2', $entry->getText());
$entry = $ifd0_mn_cs->getEntry(22); // LensModel
$this->assertInstanceOf('lsolesen\pel\PelEntrySShort', $entry);
$this->assertEquals(747, $entry->getValue());
// Tamron 150-600mm G2
$this->assertEquals('Canon EF 100-400mm f/4.5-5.6L IS II USM or Tamron Lens', $entry->getText());
$this->assertEquals(0, count(Pel::getExceptions()));
}
}

View File

@@ -0,0 +1,416 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class CanonIxusIITest extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/canon-ixus-ii.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 8);
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'Canon');
$this->assertEquals($entry->getText(), 'Canon');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'Canon DIGITAL IXUS II');
$this->assertEquals($entry->getText(), 'Canon DIGITAL IXUS II');
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'right - top');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 180,
1 => 1
]);
$this->assertEquals($entry->getText(), '180/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 180,
1 => 1
]);
$this->assertEquals($entry->getText(), '180/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1089488628);
$this->assertEquals($entry->getText(), '2004:07:10 19:43:48');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'centered');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 29);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 1,
1 => 30
]);
$this->assertEquals($entry->getText(), '1/30 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 32,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/3.2');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.2);
$this->assertEquals($entry->getText(), 'Exif Version 2.2');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1089488628);
$this->assertEquals($entry->getText(), '2004:07:10 19:43:48');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1089488628);
$this->assertEquals($entry->getText(), '2004:07:10 19:43:48');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2,
1 => 1
]);
$this->assertEquals($entry->getText(), '2/1');
$entry = $ifd0_0->getEntry(37377); // ShutterSpeedValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 157,
1 => 32
]);
$this->assertEquals($entry->getText(), '157/32 sec. (APEX: 5)');
$entry = $ifd0_0->getEntry(37378); // ApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 107,
1 => 32
]);
$this->assertEquals($entry->getText(), 'f/3.2');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => - 1,
1 => 3
]);
$this->assertEquals($entry->getText(), '-0.3');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 107,
1 => 32
]);
$this->assertEquals($entry->getText(), '107/32');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Pattern');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 16);
$this->assertEquals($entry->getText(), 'Flash did not fire, compulsory flash mode.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 215,
1 => 32
]);
$this->assertEquals($entry->getText(), '6.7 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertNull($entry);
$entry = $ifd0_0->getEntry(37510); // UserComment
$this->assertInstanceOf('lsolesen\pel\PelEntryUserComment', $entry);
$expected = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($entry->getValue(), $expected);
$expected = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($entry->getText(), $expected);
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 640);
$this->assertEquals($entry->getText(), '640');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 480);
$this->assertEquals($entry->getText(), '480');
$entry = $ifd0_0->getEntry(41486); // FocalPlaneXResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 640000,
1 => 208
]);
$this->assertEquals($entry->getText(), '640000/208');
$entry = $ifd0_0->getEntry(41487); // FocalPlaneYResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 480000,
1 => 156
]);
$this->assertEquals($entry->getText(), '480000/156');
$entry = $ifd0_0->getEntry(41488); // FocalPlaneResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0_0->getEntry(41495); // SensingMethod
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'One-chip color area sensor');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41985); // CustomRendered
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal process');
$entry = $ifd0_0->getEntry(41986); // ExposureMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Manual exposure');
$entry = $ifd0_0->getEntry(41987); // WhiteBalance
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Manual white balance');
$entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2048,
1 => 2048
]);
$this->assertEquals($entry->getText(), '2048/2048');
$entry = $ifd0_0->getEntry(41990); // SceneCaptureType
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Standard');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 2);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getEntries()), 4);
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'R98');
$this->assertEquals($entry->getText(), 'R98');
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Interoperability Version 1.0');
$entry = $ifd0_0_0->getEntry(4097); // RelatedImageWidth
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 640);
$this->assertEquals($entry->getText(), '640');
$entry = $ifd0_0_0->getEntry(4098); // RelatedImageLength
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 480);
$this->assertEquals($entry->getText(), '480');
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 4);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 180,
1 => 1
]);
$this->assertEquals($entry->getText(), '180/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 180,
1 => 1
]);
$this->assertEquals($entry->getText(), '180/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/canon-ixus-ii-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
/* Start of IDF $ifd0_mn */
$ifd0_mn = $ifd0_0->getSubIfd(5); // IFD MakerNotes
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_mn);
$entry = $ifd0_mn->getEntry(6); // ImageType
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'IMG:DIGITAL IXUS II JPEG');
$entry = $ifd0_mn->getEntry(7); // FirmwareVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'Firmware Version 1.00');
$entry = $ifd0_mn->getEntry(8); // FileNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), '1202044');
/* Start of IDF $ifd0_mn_cs. */
$ifd0_mn_cs = $ifd0_mn->getSubIfd(6); // CameraSettings
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_mn_cs);
$this->assertEquals(count($ifd0_mn_cs->getEntries()), 37);
$entry = $ifd0_mn_cs->getEntry(1); // MacroMode
$this->assertInstanceOf('lsolesen\pel\PelEntrySShort', $entry);
$this->assertEquals($entry->getValue(), '2');
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_mn_cs->getEntry(9); // RecordMode
$this->assertInstanceOf('lsolesen\pel\PelEntrySShort', $entry);
$this->assertEquals($entry->getValue(), '1');
$this->assertEquals($entry->getText(), 'JPEG');
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

View File

@@ -0,0 +1,414 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class CanonPowershotS60Test extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/canon-powershot-s60.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 8);
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'Canon');
$this->assertEquals($entry->getText(), 'Canon');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'Canon PowerShot S60');
$this->assertEquals($entry->getText(), 'Canon PowerShot S60');
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'top - left');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 180,
1 => 1
]);
$this->assertEquals($entry->getText(), '180/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 180,
1 => 1
]);
$this->assertEquals($entry->getText(), '180/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1097316018);
$this->assertEquals($entry->getText(), '2004:10:09 10:00:18');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'centered');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 29);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 1,
1 => 8
]);
$this->assertEquals($entry->getText(), '1/8 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 53,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/5.3');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.2);
$this->assertEquals($entry->getText(), 'Exif Version 2.2');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1097316018);
$this->assertEquals($entry->getText(), '2004:10:09 10:00:18');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1097316018);
$this->assertEquals($entry->getText(), '2004:10:09 10:00:18');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2,
1 => 1
]);
$this->assertEquals($entry->getText(), '2/1');
$entry = $ifd0_0->getEntry(37377); // ShutterSpeedValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 96,
1 => 32
]);
$this->assertEquals($entry->getText(), '96/32 sec. (APEX: 2)');
$entry = $ifd0_0->getEntry(37378); // ApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 154,
1 => 32
]);
$this->assertEquals($entry->getText(), 'f/5.3');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 3
]);
$this->assertEquals($entry->getText(), '0.0');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 154,
1 => 32
]);
$this->assertEquals($entry->getText(), '154/32');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Pattern');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 16);
$this->assertEquals($entry->getText(), 'Flash did not fire, compulsory flash mode.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 662,
1 => 32
]);
$this->assertEquals($entry->getText(), '20.7 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertNull($entry);
$entry = $ifd0_0->getEntry(37510); // UserComment
$this->assertInstanceOf('lsolesen\pel\PelEntryUserComment', $entry);
$expected = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($entry->getValue(), $expected);
$expected = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($entry->getText(), $expected);
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 640);
$this->assertEquals($entry->getText(), '640');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 480);
$this->assertEquals($entry->getText(), '480');
$entry = $ifd0_0->getEntry(41486); // FocalPlaneXResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 640000,
1 => 283
]);
$this->assertEquals($entry->getText(), '640000/283');
$entry = $ifd0_0->getEntry(41487); // FocalPlaneYResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 480000,
1 => 212
]);
$this->assertEquals($entry->getText(), '480000/212');
$entry = $ifd0_0->getEntry(41488); // FocalPlaneResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0_0->getEntry(41495); // SensingMethod
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'One-chip color area sensor');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41985); // CustomRendered
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal process');
$entry = $ifd0_0->getEntry(41986); // ExposureMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto exposure');
$entry = $ifd0_0->getEntry(41987); // WhiteBalance
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto white balance');
$entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2592,
1 => 2592
]);
$this->assertEquals($entry->getText(), '2592/2592');
$entry = $ifd0_0->getEntry(41990); // SceneCaptureType
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Standard');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 2);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getEntries()), 4);
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'R98');
$this->assertEquals($entry->getText(), 'R98');
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Interoperability Version 1.0');
$entry = $ifd0_0_0->getEntry(4097); // RelatedImageWidth
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 640);
$this->assertEquals($entry->getText(), '640');
$entry = $ifd0_0_0->getEntry(4098); // RelatedImageLength
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 480);
$this->assertEquals($entry->getText(), '480');
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 4);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 180,
1 => 1
]);
$this->assertEquals($entry->getText(), '180/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 180,
1 => 1
]);
$this->assertEquals($entry->getText(), '180/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/canon-powershot-s60-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
/* Start of IDF $ifd0_mn */
$ifd0_mn = $ifd0_0->getSubIfd(5); // IFD MakerNotes
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_mn);
$entry = $ifd0_mn->getEntry(6); // ImageType
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'IMG:PowerShot S60 JPEG');
$entry = $ifd0_mn->getEntry(7); // FirmwareVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'Firmware Version 1.00');
$entry = $ifd0_mn->getEntry(8); // FileNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), '1000041');
/* Start of IDF $ifd0_mn_cs. */
$ifd0_mn_cs = $ifd0_mn->getSubIfd(6); // CameraSettings
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_mn_cs);
$this->assertEquals(count($ifd0_mn_cs->getEntries()), 37);
$entry = $ifd0_mn_cs->getEntry(1); // MacroMode
$this->assertInstanceOf('lsolesen\pel\PelEntrySShort', $entry);
$this->assertEquals($entry->getValue(), '2');
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_mn_cs->getEntry(9); // RecordMode
$this->assertInstanceOf('lsolesen\pel\PelEntrySShort', $entry);
$this->assertEquals($entry->getValue(), '1');
$this->assertEquals($entry->getText(), 'JPEG');
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

View File

@@ -0,0 +1,419 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class LeicaDLuxTest extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/leica-d-lux.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 10);
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'LEICA');
$this->assertEquals($entry->getText(), 'LEICA');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'D-LUX');
$this->assertEquals($entry->getText(), 'D-LUX');
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'top - left');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(305); // Software
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'Ver1.06');
$this->assertEquals($entry->getText(), 'Ver1.06');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1099994128);
$this->assertEquals($entry->getText(), '2004:11:09 09:55:28');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'co-sited');
$entry = $ifd0->getEntry(50341); // PrintIM
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x50\x72\x69\x6e\x74\x49\x4d\0\x30\x32\x35\x30\0\0\x0e\0\x01\0\x16\0\x16\0\x02\0\0\0\0\0\x03\0\x64\0\0\0\x07\0\0\0\0\0\x08\0\0\0\0\0\x09\0\0\0\0\0\x0a\0\0\0\0\0\x0b\0\xac\0\0\0\x0c\0\0\0\0\0\x0d\0\0\0\0\0\x0e\0\xc4\0\0\0\0\x01\x05\0\0\0\x01\x01\x01\0\0\0\x10\x01\x80\0\0\0\x09\x11\0\0\x10\x27\0\0\x0b\x0f\0\0\x10\x27\0\0\x37\x05\0\0\x10\x27\0\0\xb0\x08\0\0\x10\x27\0\0\x01\x1c\0\0\x10\x27\0\0\x5e\x02\0\0\x10\x27\0\0\x8b\0\0\0\x10\x27\0\0\xcb\x03\0\0\x10\x27\0\0\xe5\x1b\0\0\x10\x27\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '(undefined)');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 37);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 10,
1 => 1000
]);
$this->assertEquals($entry->getText(), '1/100 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 97,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/9.7');
$entry = $ifd0_0->getEntry(34850); // ExposureProgram
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Normal program');
$entry = $ifd0_0->getEntry(34855); // ISOSpeedRatings
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 100);
$this->assertEquals($entry->getText(), '100');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.2);
$this->assertEquals($entry->getText(), 'Exif Version 2.2');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1099994128);
$this->assertEquals($entry->getText(), '2004:11:09 09:55:28');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1099994128);
$this->assertEquals($entry->getText(), '2004:11:09 09:55:28');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0" . '');
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 21,
1 => 10
]);
$this->assertEquals($entry->getText(), '21/10');
$entry = $ifd0_0->getEntry(37377); // ShutterSpeedValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 6644,
1 => 1000
]);
$this->assertEquals($entry->getText(), '6644/1000 sec. (APEX: 10)');
$entry = $ifd0_0->getEntry(37378); // ApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 66,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/9.8');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 100
]);
$this->assertEquals($entry->getText(), '0.0');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 30,
1 => 10
]);
$this->assertEquals($entry->getText(), '30/10');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 3);
$this->assertEquals($entry->getText(), 'Spot');
$entry = $ifd0_0->getEntry(37384); // LightSource
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Daylight');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 24);
$this->assertEquals($entry->getText(), 'Flash did not fire, auto mode.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 88,
1 => 10
]);
$this->assertEquals($entry->getText(), '8.8 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x4c\x45\x49\x43\x41\0\0\0\x0b\0\x01\0\x03\0\x01\0\0\0\x03\0\0\0\x02\0\x07\0\x04\0\0\0\x30\x31\x30\x30\x03\0\x03\0\x01\0\0\0\x01\0\0\0\x07\0\x03\0\x01\0\0\0\x01\0\0\0\x0f\0\x01\0\x02\0\0\0\0\x10\0\0\x1a\0\x03\0\x01\0\0\0\x02\0\0\0\x1c\0\x03\0\x01\0\0\0\x02\0\0\0\x1f\0\x03\0\x01\0\0\0\x01\0\0\0\x20\0\x03\0\x01\0\0\0\x02\0\0\0\x21\0\x07\0\x72\0\0\0\x5e\x04\0\0\x22\0\x03\0\x01\0\0\0\0\0\0\0\x57\x42\x02\x62\x01\x36\0\xb9\0\x92\0\xa8\0\x8c\0\xdc\0\xa0\0\x4b\x01\x9c\x01\xd5\x02\x3b\x01\x1c\x02\x44\x01\x1d\x0b\xab\x1b\x6c\x16\xb8\0\0\x41\x46\x01\x96\x04\x8e\x20\x06\0\0\x53\x54\0\0\0\0\0\0\x01\x24\0\0\0\0\0\0\0\x05\0\x05\0\0\x41\x45\x06\xa7\0\x4c\0\0\x02\x28\x09\x01\0\x93\x01\x44\0\0\x08\x08\x08\x08\x03\x03\0\0\0\xe0\0\0\x20\x20\0\x0a\0\0\x45\x50\x01\x0a\0\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '256 bytes unknown MakerNote data');
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 640);
$this->assertEquals($entry->getText(), '640');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 480);
$this->assertEquals($entry->getText(), '480');
$entry = $ifd0_0->getEntry(41495); // SensingMethod
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'One-chip color area sensor');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41729); // SceneType
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01");
$this->assertEquals($entry->getText(), 'Directly photographed');
$entry = $ifd0_0->getEntry(41730); // CFAPattern
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\0\x02\0\x02\0\x01\x01\x02");
$this->assertEquals($entry->getText(), '(undefined)');
$entry = $ifd0_0->getEntry(41985); // CustomRendered
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal process');
$entry = $ifd0_0->getEntry(41986); // ExposureMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto exposure');
$entry = $ifd0_0->getEntry(41987); // WhiteBalance
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto white balance');
$entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 10
]);
$this->assertEquals($entry->getText(), '0/10');
$entry = $ifd0_0->getEntry(41989); // FocalLengthIn35mmFilm
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 53);
$this->assertEquals($entry->getText(), '53');
$entry = $ifd0_0->getEntry(41990); // SceneCaptureType
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Standard');
$entry = $ifd0_0->getEntry(41991); // GainControl
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41992); // Contrast
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41993); // Saturation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41994); // Sharpness
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41996); // SubjectDistanceRange
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Close view');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 1);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getEntries()), 2);
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'R98');
$this->assertEquals($entry->getText(), 'R98');
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Interoperability Version 1.0');
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 5);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd1->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'co-sited');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/leica-d-lux-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

View File

@@ -0,0 +1,166 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class NikonCoolscanIVTest extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/nikon-coolscan-iv.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 6);
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'Nikon');
$this->assertEquals($entry->getText(), 'Nikon');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2000,
1 => 1
]);
$this->assertEquals($entry->getText(), '2000/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2000,
1 => 1
]);
$this->assertEquals($entry->getText(), '2000/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1090023875);
$this->assertEquals($entry->getText(), '2004:07:17 00:24:35');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'centered');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 2);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 7);
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.1);
$this->assertEquals($entry->getText(), 'Exif Version 2.1');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$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";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '32 bytes unknown MakerNote data');
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 960);
$this->assertEquals($entry->getText(), '960');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 755);
$this->assertEquals($entry->getText(), '755');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$ifd0_1 = $ifd0->getSubIfd(3); // IFD GPS
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_1);
/* Start of IDF $ifd0_1. */
$this->assertEquals(count($ifd0_1->getEntries()), 0);
/* Sub IFDs of $ifd0_1. */
$this->assertEquals(count($ifd0_1->getSubIfds()), 0);
$this->assertEquals($ifd0_1->getThumbnailData(), '');
/* Next IFD. */
$ifd0_2 = $ifd0_1->getNextIfd();
$this->assertNull($ifd0_2);
/* End of IFD $ifd0_1. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertNull($ifd1);
/* End of IFD $ifd0. */
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

View File

@@ -0,0 +1,313 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class NikonE5000Test extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/nikon-e5000.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 9);
$entry = $ifd0->getEntry(270); // ImageDescription
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), ' ');
$this->assertEquals($entry->getText(), ' ');
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'NIKON');
$this->assertEquals($entry->getText(), 'NIKON');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'E5000');
$this->assertEquals($entry->getText(), 'E5000');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 300,
1 => 1
]);
$this->assertEquals($entry->getText(), '300/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 300,
1 => 1
]);
$this->assertEquals($entry->getText(), '300/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(305); // Software
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'E5000v1.6');
$this->assertEquals($entry->getText(), 'E5000v1.6');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1021992832);
$this->assertEquals($entry->getText(), '2002:05:21 14:53:52');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'centered');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 2);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 22);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 1642036,
1 => 100000000
]);
$this->assertEquals($entry->getText(), '1/60 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 28,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/2.8');
$entry = $ifd0_0->getEntry(34850); // ExposureProgram
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Normal program');
$entry = $ifd0_0->getEntry(34855); // ISOSpeedRatings
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 100);
$this->assertEquals($entry->getText(), '100');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.1);
$this->assertEquals($entry->getText(), 'Exif Version 2.1');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1021992832);
$this->assertEquals($entry->getText(), '2002:05:21 14:53:52');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1021992832);
$this->assertEquals($entry->getText(), '2002:05:21 14:53:52');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 10
]);
$this->assertEquals($entry->getText(), '0.0');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 3,
1 => 1
]);
$this->assertEquals($entry->getText(), '3/1');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Pattern');
$entry = $ifd0_0->getEntry(37384); // LightSource
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Unknown');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Flash did not fire.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 71,
1 => 10
]);
$this->assertEquals($entry->getText(), '7.1 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x15\0\x01\0\x07\0\x04\0\0\0\0\x01\0\0\x02\0\x03\0\x02\0\0\0\0\0\0\0\x03\0\x02\0\x06\0\0\0\xbc\x03\0\0\x04\0\x02\0\x08\0\0\0\xc2\x03\0\0\x05\0\x02\0\x0d\0\0\0\xca\x03\0\0\x06\0\x02\0\x07\0\0\0\xd8\x03\0\0\x07\0\x02\0\x07\0\0\0\xe0\x03\0\0\x08\0\x02\0\x0d\0\0\0\xe8\x03\0\0\x0a\0\x05\0\x01\0\0\0\xf6\x03\0\0\x0f\0\x02\0\x07\0\0\0\xfe\x03\0\0\x11\0\x04\0\x01\0\0\0\x14\x05\0\0\x80\0\x02\0\x0e\0\0\0\x06\x04\0\0\x82\0\x02\0\x0d\0\0\0\x14\x04\0\0\x85\0\x05\0\x01\0\0\0\x22\x04\0\0\x86\0\x05\0\x01\0\0\0\x2a\x04\0\0\x88\0\x07\0\x04\0\0\0\0\0\0\0\x8f\0\x02\0\x11\0\0\0\x32\x04\0\0\x94\0\x08\0\x01\0\0\0\0\0\0\0\x95\0\x02\0\x05\0\0\0\x44\x04\0\0\0\x0e\x07\0\xca\0\0\0\x4a\x04\0\0\x10\x0e\x04\0\x01\0\0\0\x72\x05\0\0\0\0\0\0\x43\x4f\x4c\x4f\x52\0\x46\x49\x4e\x45\x20\x20\x20\0\x41\x55\x54\x4f\x20\x20\x20\x20\x20\x20\x20\x20\0\x31\x41\x55\x54\x4f\x20\x20\0\0\x41\x46\x2d\x43\x20\x20\0\x3a\x4e\x4f\x52\x4d\x41\x4c\x20\x20\x20\x20\x20\x20\0\0\x80\x22\0\0\xe8\x03\0\0\x41\x55\x54\x4f\x20\x20\0\0\x41\x55\x54\x4f\x20\x20\x20\x20\x20\x20\x20\x20\x20\0\x4f\x46\x46\x20\x20\x20\x20\x20\x20\x20\x20\x20\0\x20\0\0\0\0\0\0\0\0\x01\0\0\0\x01\0\0\0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\0\x20\x4f\x46\x46\x20\0\x20\x50\x72\x69\x6e\x74\x49\x4d\0\x30\x31\x30\x30\0\0\x0d\0\x01\0\x16\0\x16\0\x02\0\x01\0\0\0\x03\0\x5e\0\0\0\x07\0\0\0\0\0\x08\0\0\0\0\0\x09\0\0\0\0\0\x0a\0\0\0\0\0\x0b\0\xa6\0\0\0\x0c\0\0\0\0\0\x0d\0\0\0\0\0\x0e\0\xbe\0\0\0\0\x01\x05\0\0\0\x01\x01\x01\0\0\0\x09\x11\0\0\x10\x27\0\0\x0b\x0f\0\0\x10\x27\0\0\x97\x05\0\0\x10\x27\0\0\xb0\x08\0\0\x10\x27\0\0\x01\x1c\0\0\x10\x27\0\0\x5e\x02\0\0\x10\x27\0\0\x8b\0\0\0\x10\x27\0\0\xcb\x03\0\0\x10\x27\0\0\xe5\x1b\0\0\x10\x27\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x06\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '604 bytes unknown MakerNote data');
$entry = $ifd0_0->getEntry(37510); // UserComment
$this->assertInstanceOf('lsolesen\pel\PelEntryUserComment', $entry);
$this->assertEquals($entry->getValue(), ' ');
$this->assertEquals($entry->getText(), ' ');
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 1600);
$this->assertEquals($entry->getText(), '1600');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 1200);
$this->assertEquals($entry->getText(), '1200');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41729); // SceneType
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01");
$this->assertEquals($entry->getText(), 'Directly photographed');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$ifd0_1 = $ifd0->getSubIfd(3); // IFD GPS
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_1);
/* Start of IDF $ifd0_1. */
$this->assertEquals(count($ifd0_1->getEntries()), 0);
/* Sub IFDs of $ifd0_1. */
$this->assertEquals(count($ifd0_1->getSubIfds()), 0);
$this->assertEquals($ifd0_1->getThumbnailData(), '');
/* Next IFD. */
$ifd0_2 = $ifd0_1->getNextIfd();
$this->assertNull($ifd0_2);
/* End of IFD $ifd0_1. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 4);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/nikon-e5000-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
$exceptions = Pel::getExceptions();
$this->assertInstanceOf('lsolesen\pel\PelException', $exceptions[0]);
$this->assertEquals($exceptions[0]->getMessage(), 'Found trailing content after EOI: 1396 bytes');
}
}

View File

@@ -0,0 +1,334 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class NikonE950Test extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/nikon-e950.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 10);
$entry = $ifd0->getEntry(270); // ImageDescription
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), ' ');
$this->assertEquals($entry->getText(), ' ');
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'NIKON');
$this->assertEquals($entry->getText(), 'NIKON');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'E950');
$this->assertEquals($entry->getText(), 'E950');
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'top - left');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 300,
1 => 1
]);
$this->assertEquals($entry->getText(), '300/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 300,
1 => 1
]);
$this->assertEquals($entry->getText(), '300/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(305); // Software
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'v981p-78');
$this->assertEquals($entry->getText(), 'v981p-78');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 978276013);
$this->assertEquals($entry->getText(), '2000:12:31 15:20:13');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'co-sited');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 23);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 10,
1 => 1120
]);
$this->assertEquals($entry->getText(), '1/112 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 60,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/6.0');
$entry = $ifd0_0->getEntry(34850); // ExposureProgram
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Normal program');
$entry = $ifd0_0->getEntry(34855); // ISOSpeedRatings
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 80);
$this->assertEquals($entry->getText(), '80');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.1);
$this->assertEquals($entry->getText(), 'Exif Version 2.1');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 978276013);
$this->assertEquals($entry->getText(), '2000:12:31 15:20:13');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 978276013);
$this->assertEquals($entry->getText(), '2000:12:31 15:20:13');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 4,
1 => 1
]);
$this->assertEquals($entry->getText(), '4/1');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 10
]);
$this->assertEquals($entry->getText(), '0.0');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 26,
1 => 10
]);
$this->assertEquals($entry->getText(), '26/10');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Pattern');
$entry = $ifd0_0->getEntry(37384); // LightSource
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Unknown');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Flash did not fire.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 158,
1 => 10
]);
$this->assertEquals($entry->getText(), '15.8 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x4e\x69\x6b\x6f\x6e\0\x01\0\x0b\0\x02\0\x02\0\x06\0\0\0\x26\x04\0\0\x03\0\x03\0\x01\0\0\0\x0c\0\0\0\x04\0\x03\0\x01\0\0\0\x01\0\0\0\x05\0\x03\0\x01\0\0\0\0\0\0\0\x06\0\x03\0\x01\0\0\0\0\0\0\0\x07\0\x03\0\x01\0\0\0\0\0\0\0\x08\0\x05\0\x01\0\0\0\x2c\x04\0\0\x09\0\x02\0\x14\0\0\0\x34\x04\0\0\x0a\0\x05\0\x01\0\0\0\x48\x04\0\0\x0b\0\x03\0\x01\0\0\0\0\0\0\0\0\x0f\x04\0\x1e\0\0\0\x50\x04\0\0\0\0\0\0\x30\x38\x2e\x30\x30\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x64\0\0\0\x01\x3e\0\x80\x01\x58\0\0\0\0\xff\x01\0\0\0\0\x0c\xe5\x10\x8c\0\0\0\0\x0a\x5b\0\0\x18\x6a\0\0\x23\x04\0\0\x11\x16\0\0\x11\x16\0\0\x1f\x05\x0c\x9f\0\x2f\0\0\0\0\x01\xcb\x02\x27\x02\x7b\x02\xd8\x03\x6a\x08\x5c\0\0\0\0\x10\x0e\x15\0\0\x01\x60\0\0\x30\0\0\0\x10\0\0\x5b\x18\x02\0\x48\x04\x16\x68\0\x0b\x58\x29\0\x3f\0\0\x15\x19\x15\x1a\x0f\xe1\x42\0\xff\0\x4f\x5d\x32\x0c\xa1\x02\0\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '308 bytes unknown MakerNote data');
$entry = $ifd0_0->getEntry(37510); // UserComment
$this->assertInstanceOf('lsolesen\pel\PelEntryUserComment', $entry);
$this->assertEquals($entry->getValue(), ' ');
$this->assertEquals($entry->getText(), ' ');
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 1600);
$this->assertEquals($entry->getText(), '1600');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 1200);
$this->assertEquals($entry->getText(), '1200');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41729); // SceneType
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01");
$this->assertEquals($entry->getText(), 'Directly photographed');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 1);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getEntries()), 2);
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'R98');
$this->assertEquals($entry->getText(), 'R98');
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Interoperability Version 1.0');
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 4);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 300,
1 => 1
]);
$this->assertEquals($entry->getText(), '300/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 300,
1 => 1
]);
$this->assertEquals($entry->getText(), '300/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/nikon-e950-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

View File

@@ -0,0 +1,388 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class OlympusC5050zTest extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/olympus-c5050z.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 11);
$entry = $ifd0->getEntry(270); // ImageDescription
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'OLYMPUS DIGITAL CAMERA ');
$this->assertEquals($entry->getText(), 'OLYMPUS DIGITAL CAMERA ');
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'OLYMPUS OPTICAL CO.,LTD');
$this->assertEquals($entry->getText(), 'OLYMPUS OPTICAL CO.,LTD');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'C5050Z');
$this->assertEquals($entry->getText(), 'C5050Z');
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'top - left');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(305); // Software
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'v558-83');
$this->assertEquals($entry->getText(), 'v558-83');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), false);
$this->assertEquals($entry->getText(), '0000:00:00 00:00:00');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'co-sited');
$entry = $ifd0->getEntry(50341); // PrintIM
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x50\x72\x69\x6e\x74\x49\x4d\0\x30\x32\x35\x30\0\0\x14\0\x01\0\x14\0\x14\0\x02\0\x01\0\0\0\x03\0\x88\0\0\0\x07\0\0\0\0\0\x08\0\0\0\0\0\x09\0\0\0\0\0\x0a\0\0\0\0\0\x0b\0\xd0\0\0\0\x0c\0\0\0\0\0\x0d\0\0\0\0\0\x0e\0\xe8\0\0\0\0\x01\x01\0\0\0\x01\x01\xff\0\0\0\x02\x01\x83\0\0\0\x03\x01\x83\0\0\0\x04\x01\x80\0\0\0\x05\x01\x83\0\0\0\x06\x01\x83\0\0\0\x07\x01\x80\x80\x80\0\x10\x01\x80\0\0\0\x09\x11\0\0\x10\x27\0\0\x0b\x0f\0\0\x10\x27\0\0\x97\x05\0\0\x10\x27\0\0\xb0\x08\0\0\x10\x27\0\0\x01\x1c\0\0\x10\x27\0\0\x5e\x02\0\0\x10\x27\0\0\x8b\0\0\0\x10\x27\0\0\xcb\x03\0\0\x10\x27\0\0\xe5\x1b\0\0\x10\x27\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '(undefined)');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 32);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 10,
1 => 40
]);
$this->assertEquals($entry->getText(), '1/4 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 26,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/2.6');
$entry = $ifd0_0->getEntry(34850); // ExposureProgram
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Normal program');
$entry = $ifd0_0->getEntry(34855); // ISOSpeedRatings
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 64);
$this->assertEquals($entry->getText(), '64');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.2);
$this->assertEquals($entry->getText(), 'Exif Version 2.2');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), false);
$this->assertEquals($entry->getText(), '0000:00:00 00:00:00');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), false);
$this->assertEquals($entry->getText(), '0000:00:00 00:00:00');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2,
1 => 1
]);
$this->assertEquals($entry->getText(), '2/1');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 10
]);
$this->assertEquals($entry->getText(), '0.0');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 28,
1 => 10
]);
$this->assertEquals($entry->getText(), '28/10');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Pattern');
$entry = $ifd0_0->getEntry(37384); // LightSource
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Unknown');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 16);
$this->assertEquals($entry->getText(), 'Flash did not fire, compulsory flash mode.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 213,
1 => 10
]);
$this->assertEquals($entry->getText(), '21.3 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x4f\x4c\x59\x4d\x50\0\x01\0\x10\0\0\x02\x04\0\x03\0\0\0\xd6\x05\0\0\x01\x02\x03\0\x01\0\0\0\x01\0\0\0\x02\x02\x03\0\x01\0\0\0\0\0\0\0\x03\x02\x03\0\x01\0\0\0\0\0\0\0\x04\x02\x05\0\x01\0\0\0\xe2\x05\0\0\x05\x02\x05\0\x01\0\0\0\xea\x05\0\0\x06\x02\x08\0\x06\0\0\0\xf2\x05\0\0\x07\x02\x02\0\x08\0\0\0\xfe\x05\0\0\x08\x02\x02\0\x34\0\0\0\x06\x06\0\0\x09\x02\x07\0\x20\0\0\0\x42\x06\0\0\0\x03\x03\0\x01\0\0\0\0\0\0\0\x01\x03\x03\0\x01\0\0\0\0\0\0\0\x02\x03\x03\0\x01\0\0\0\x01\0\0\0\x03\x03\x03\0\x01\0\0\0\0\0\0\0\x04\x03\x03\0\x01\0\0\0\0\0\0\0\0\x0f\x07\0\xfe\0\0\0\x62\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x64\0\0\0\x64\0\0\0\x88\x03\0\0\x64\0\0\0\x03\0\x0d\0\x12\0\x19\0\x38\0\x49\0\x53\x58\x35\x35\x38\0\0\0\x5b\x70\x69\x63\x74\x75\x72\x65\x49\x6e\x66\x6f\x5d\x20\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3d\x31\x20\x5b\x43\x61\x6d\x65\x72\x61\x20\x49\x6e\x66\x6f\x5d\x20\x54\x79\x70\x65\x3d\x53\x58\x35\x35\x38\0\0\0\0\0\0\0\0\0\x4f\x4c\x59\x4d\x50\x55\x53\x20\x44\x49\x47\x49\x54\x41\x4c\x20\x43\x41\x4d\x45\x52\x41\0\xff\xff\xff\xff\xff\xff\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x31\xcf\x13\0\0\0\0\x01\xe8\x48\0\0\x03\xb5\0\x01\xe5\xd3\0\0\x14\x55\0\0\x14\x55\x01\0\x1f\0\x0b\xa9\0\x12\x03\x31\x01\0\x01\xc0\x01\xe6\x01\xfc\x01\xe9\xd0\0\0\xe8\x11\x4a\0\0\x14\x14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x0b\x1c\0\0\x40\0\x0b\x19\0\0\0\x67\0\0\0\x67\0\xe8\x16\x49\0\0\0\x12\0\x03\xcb\xa6\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x19\x61\x12\x31\0\x76\x01\x3f\x01\xcf\x02\x59\x01\x15\x02\0\x02\x9c\0\x30\x0b\x95\x0d\x14\x02\0\0\xc9\x03\x8b\x02\0\x01\x6e\x03\x93\x03\xed\x01\x72\x01\0\xd0\x5b\0\x0c\0\x0c\0\x02\x03\x52\0\x01\0\0\0\0\0\x09\0\x32\0\x0a\0\0\0\x01\0\x48\0\x87\0\x64\0\x78\x0e\x0e\x0e\x0e\x11\x11\x11\x11\0\0\0\0\0\0\x14\x1d\x0e\x17\0\0\x0a\0\x1b\0\0\x1a\0\0\0\0\x01\0\x32\x0f\x42\x40\x0f\0\0\x64\x2a\x20\0\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '600 bytes unknown MakerNote data');
$entry = $ifd0_0->getEntry(37510); // UserComment
$this->assertInstanceOf('lsolesen\pel\PelEntryUserComment', $entry);
$this->assertEquals($entry->getValue(), ' ');
$this->assertEquals($entry->getText(), ' ');
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 640);
$this->assertEquals($entry->getText(), '640');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 480);
$this->assertEquals($entry->getText(), '480');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41729); // SceneType
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01");
$this->assertEquals($entry->getText(), 'Directly photographed');
$entry = $ifd0_0->getEntry(41985); // CustomRendered
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal process');
$entry = $ifd0_0->getEntry(41986); // ExposureMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto exposure');
$entry = $ifd0_0->getEntry(41987); // WhiteBalance
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Manual white balance');
$entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 100
]);
$this->assertEquals($entry->getText(), '0/100');
$entry = $ifd0_0->getEntry(41990); // SceneCaptureType
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Standard');
$entry = $ifd0_0->getEntry(41991); // GainControl
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41992); // Contrast
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41993); // Saturation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41994); // Sharpness
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 1);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getEntries()), 2);
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'R98');
$this->assertEquals($entry->getText(), 'R98');
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Interoperability Version 1.0');
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 4);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/olympus-c5050z-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

View File

@@ -0,0 +1,375 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class OlympusC50zTest extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/olympus-c50z.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 11);
$entry = $ifd0->getEntry(270); // ImageDescription
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'OLYMPUS DIGITAL CAMERA ');
$this->assertEquals($entry->getText(), 'OLYMPUS DIGITAL CAMERA ');
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'OLYMPUS OPTICAL CO.,LTD');
$this->assertEquals($entry->getText(), 'OLYMPUS OPTICAL CO.,LTD');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'X-2,C-50Z ');
$this->assertEquals($entry->getText(), 'X-2,C-50Z ');
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'top - left');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 144,
1 => 1
]);
$this->assertEquals($entry->getText(), '144/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 144,
1 => 1
]);
$this->assertEquals($entry->getText(), '144/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(305); // Software
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), '28-1012 ');
$this->assertEquals($entry->getText(), '28-1012 ');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), false);
$this->assertEquals($entry->getText(), '0000:00:00 00:00:00');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'co-sited');
$entry = $ifd0->getEntry(50341); // PrintIM
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x50\x72\x69\x6e\x74\x49\x4d\0\x30\x32\x35\x30\0\0\x14\0\x01\0\x12\0\x12\0\x02\0\x01\0\0\0\x03\0\x88\0\0\0\x07\0\0\0\0\0\x08\0\0\0\0\0\x09\0\0\0\0\0\x0a\0\0\0\0\0\x0b\0\xd0\0\0\0\x0c\0\0\0\0\0\x0d\0\0\0\0\0\x0e\0\xe8\0\0\0\0\x01\x01\0\0\0\x01\x01\xff\0\0\0\x02\x01\x80\0\0\0\x03\x01\x80\0\0\0\x04\x01\x80\0\0\0\x05\x01\x80\0\0\0\x06\x01\x80\0\0\0\x07\x01\x80\x80\x80\0\x10\x01\x80\0\0\0\x09\x11\0\0\x10\x27\0\0\x0b\x0f\0\0\x10\x27\0\0\x97\x05\0\0\x10\x27\0\0\xb0\x08\0\0\x10\x27\0\0\x01\x1c\0\0\x10\x27\0\0\x5e\x02\0\0\x10\x27\0\0\x8b\0\0\0\x10\x27\0\0\xcb\x03\0\0\x10\x27\0\0\xe5\x1b\0\0\x10\x27\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '(undefined)');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 30);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 1,
1 => 80
]);
$this->assertEquals($entry->getText(), '1/80 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 45,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/4.5');
$entry = $ifd0_0->getEntry(34850); // ExposureProgram
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Creative program (biased toward depth of field)');
$entry = $ifd0_0->getEntry(34855); // ISOSpeedRatings
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 80);
$this->assertEquals($entry->getText(), '80');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.2);
$this->assertEquals($entry->getText(), 'Exif Version 2.2');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), false);
$this->assertEquals($entry->getText(), '0000:00:00 00:00:00');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), false);
$this->assertEquals($entry->getText(), '0000:00:00 00:00:00');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 10
]);
$this->assertEquals($entry->getText(), '0.0');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 300,
1 => 100
]);
$this->assertEquals($entry->getText(), '300/100');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Pattern');
$entry = $ifd0_0->getEntry(37384); // LightSource
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Unknown');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 25);
$this->assertEquals($entry->getText(), 'Flash fired, auto mode.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 1883,
1 => 100
]);
$this->assertEquals($entry->getText(), '18.8 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x4f\x4c\x59\x4d\x50\0\x01\0\x3e\0\0\x02\x04\0\x03\0\0\0\x24\x0f\0\0\x01\x02\x03\0\x01\0\0\0\x02\0\0\0\x02\x02\x03\0\x01\0\0\0\0\0\0\0\x03\x02\x03\0\x01\0\0\0\0\0\0\0\x04\x02\x05\0\x01\0\0\0\x38\x0f\0\0\x05\x02\x05\0\x01\0\0\0\x40\x0f\0\0\x06\x02\x08\0\x06\0\0\0\x48\x0f\0\0\x07\x02\x02\0\x06\0\0\0\x54\x0f\0\0\x09\x02\x07\0\x20\0\0\0\x5a\x0f\0\0\0\x10\x0a\0\x01\0\0\0\x7c\x0f\0\0\x01\x10\x0a\0\x01\0\0\0\x84\x0f\0\0\x02\x10\x0a\0\x01\0\0\0\x8c\x0f\0\0\x03\x10\x0a\0\x01\0\0\0\x94\x0f\0\0\x04\x10\x03\0\x01\0\0\0\0\0\0\0\x05\x10\x03\0\x02\0\0\0\0\0\0\0\x06\x10\x0a\0\x01\0\0\0\xa4\x0f\0\0\x09\x10\x03\0\x01\0\0\0\x01\0\0\0\x0a\x10\x03\0\x01\0\0\0\0\0\0\0\x0b\x10\x03\0\x01\0\0\0\0\0\0\0\x0c\x10\x05\0\x01\0\0\0\xb8\x0f\0\0\x0d\x10\x03\0\x01\0\0\0\x1c\0\x51\x01\x0e\x10\x03\0\x01\0\0\0\x51\x01\x02\0\x0f\x10\x03\0\x01\0\0\0\x02\0\0\0\x10\x10\x03\0\x01\0\0\0\0\0\0\0\x11\x10\x03\0\x09\0\0\0\x36\x10\0\0\x12\x10\x03\0\x04\0\0\0\x48\x10\0\0\x13\x10\x03\0\x01\0\0\0\0\0\0\0\x14\x10\x03\0\x01\0\0\0\0\0\x01\0\x15\x10\x03\0\x02\0\0\0\x01\0\0\0\x16\x10\x03\0\x01\0\0\0\0\0\x70\x01\x17\x10\x03\0\x02\0\0\0\x70\x01\x40\0\x18\x10\x03\0\x02\0\0\0\x26\x01\x40\0\x1a\x10\x02\0\x20\0\0\0\xdc\x0f\0\0\x1b\x10\x04\0\x01\0\0\0\0\0\0\0\x1c\x10\x04\0\x01\0\0\0\0\0\0\0\x1d\x10\x04\0\x01\0\0\0\xe8\xb8\x03\0\x1e\x10\x04\0\x01\0\0\0\0\0\0\0\x1f\x10\x04\0\x01\0\0\0\0\0\0\0\x20\x10\x04\0\x01\0\0\0\0\0\0\0\x21\x10\x04\0\x01\0\0\0\xb0\x27\0\0\x22\x10\x04\0\x01\0\0\0\x20\x6e\x0f\x04\x23\x10\x0a\0\x01\0\0\0\x1c\x10\0\0\x24\x10\x03\0\x01\0\0\0\x36\0\0\0\x25\x10\x0a\0\x01\0\0\0\x28\x10\0\0\x26\x10\x03\0\x01\0\0\0\0\0\0\0\x27\x10\x03\0\x01\0\0\0\0\0\0\0\x28\x10\x03\0\x01\0\0\0\0\0\x64\x01\x29\x10\x03\0\x01\0\0\0\x02\0\0\x02\x2a\x10\x03\0\x01\0\0\0\0\x02\x18\0\x2b\x10\x03\0\x06\0\0\0\x54\x10\0\0\x2c\x10\x03\0\x02\0\0\0\x0a\0\0\0\x2d\x10\x03\0\x01\0\0\0\0\x08\0\0\x2e\x10\x04\0\x01\0\0\0\0\x0a\0\0\x2f\x10\x04\0\x01\0\0\0\x80\x07\0\0\x30\x10\x03\0\x01\0\0\0\x02\0\0\0\x31\x10\x04\0\x08\0\0\0\x74\x10\0\0\x33\x10\x04\0\xd0\x02\0\0\xa0\x10\0\0\x38\x10\x03\0\x01\0\0\0\0\0\0\0\x3b\x10\x03\0\x01\0\0\0\x21\x01\xbe\x01\x3c\x10\x03\0\x01\0\0\0\xbe\x01\0\0\x3d\x10\x0a\0\x01\0\0\0\xe4\x1b\0\0\x3e\x10\x0a\0\x01\0\0\0\xec\x1b\0\0\0\0\0\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '758 bytes unknown MakerNote data');
$entry = $ifd0_0->getEntry(37510); // UserComment
$this->assertInstanceOf('lsolesen\pel\PelEntryUserComment', $entry);
$this->assertEquals($entry->getValue(), ' ');
$this->assertEquals($entry->getText(), ' ');
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2560);
$this->assertEquals($entry->getText(), '2560');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1920);
$this->assertEquals($entry->getText(), '1920');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41985); // CustomRendered
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal process');
$entry = $ifd0_0->getEntry(41986); // ExposureMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto exposure');
$entry = $ifd0_0->getEntry(41987); // WhiteBalance
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto white balance');
$entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 100,
1 => 100
]);
$this->assertEquals($entry->getText(), '100/100');
$entry = $ifd0_0->getEntry(41990); // SceneCaptureType
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Portrait');
$entry = $ifd0_0->getEntry(41991); // GainControl
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41992); // Contrast
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41993); // Saturation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41994); // Sharpness
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 1);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getEntries()), 2);
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'R98');
$this->assertEquals($entry->getText(), 'R98');
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Interoperability Version 1.0');
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 4);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/olympus-c50z-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

View File

@@ -0,0 +1,388 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class OlympusC765uzTest extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/olympus-c765uz.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 11);
$entry = $ifd0->getEntry(270); // ImageDescription
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'OLYMPUS DIGITAL CAMERA ');
$this->assertEquals($entry->getText(), 'OLYMPUS DIGITAL CAMERA ');
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'OLYMPUS CORPORATION');
$this->assertEquals($entry->getText(), 'OLYMPUS CORPORATION');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'C765UZ');
$this->assertEquals($entry->getText(), 'C765UZ');
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'top - left');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(305); // Software
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'v777-76');
$this->assertEquals($entry->getText(), 'v777-76');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1090073972);
$this->assertEquals($entry->getText(), '2004:07:17 14:19:32');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'co-sited');
$entry = $ifd0->getEntry(50341); // PrintIM
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x50\x72\x69\x6e\x74\x49\x4d\0\x30\x32\x35\x30\0\0\x14\0\x01\0\x12\0\x12\0\x02\0\x01\0\0\0\x03\0\x88\0\0\0\x07\0\0\0\0\0\x08\0\0\0\0\0\x09\0\0\0\0\0\x0a\0\0\0\0\0\x0b\0\xd0\0\0\0\x0c\0\0\0\0\0\x0d\0\0\0\0\0\x0e\0\xe8\0\0\0\0\x01\x01\0\0\0\x01\x01\xff\0\0\0\x02\x01\x80\0\0\0\x03\x01\x80\0\0\0\x04\x01\x80\0\0\0\x05\x01\x80\0\0\0\x06\x01\x80\0\0\0\x07\x01\x80\x80\x80\0\x10\x01\x80\0\0\0\x09\x11\0\0\x10\x27\0\0\x0b\x0f\0\0\x10\x27\0\0\x97\x05\0\0\x10\x27\0\0\xb0\x08\0\0\x10\x27\0\0\x01\x1c\0\0\x10\x27\0\0\x5e\x02\0\0\x10\x27\0\0\x8b\0\0\0\x10\x27\0\0\xcb\x03\0\0\x10\x27\0\0\xe5\x1b\0\0\x10\x27\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x21\0\x9a\x82\x05\0\x01\0\0\0\xb8\x03\0\0\x9d\x82";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '(undefined)');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 32);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 10,
1 => 2000
]);
$this->assertEquals($entry->getText(), '1/200 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 32,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/3.2');
$entry = $ifd0_0->getEntry(34850); // ExposureProgram
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Creative program (biased toward depth of field)');
$entry = $ifd0_0->getEntry(34855); // ISOSpeedRatings
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 64);
$this->assertEquals($entry->getText(), '64');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.2);
$this->assertEquals($entry->getText(), 'Exif Version 2.2');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1090073972);
$this->assertEquals($entry->getText(), '2004:07:17 14:19:32');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1090073972);
$this->assertEquals($entry->getText(), '2004:07:17 14:19:32');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2,
1 => 1
]);
$this->assertEquals($entry->getText(), '2/1');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 10
]);
$this->assertEquals($entry->getText(), '0.0');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 34,
1 => 10
]);
$this->assertEquals($entry->getText(), '34/10');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 5);
$this->assertEquals($entry->getText(), 'Pattern');
$entry = $ifd0_0->getEntry(37384); // LightSource
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Unknown');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 16);
$this->assertEquals($entry->getText(), 'Flash did not fire, compulsory flash mode.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 109,
1 => 10
]);
$this->assertEquals($entry->getText(), '10.9 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x4f\x4c\x59\x4d\x50\0\x01\0\x10\0\0\x02\x04\0\x03\0\0\0\xe0\x05\0\0\x01\x02\x03\0\x01\0\0\0\x01\0\0\0\x02\x02\x03\0\x01\0\0\0\x02\0\0\0\x03\x02\x03\0\x01\0\0\0\0\0\0\0\x04\x02\x05\0\x01\0\0\0\xec\x05\0\0\x05\x02\x05\0\x01\0\0\0\xf4\x05\0\0\x06\x02\x08\0\x06\0\0\0\xfc\x05\0\0\x07\x02\x02\0\x08\0\0\0\x08\x06\0\0\x08\x02\x02\0\x34\0\0\0\x10\x06\0\0\x09\x02\x07\0\x20\0\0\0\x4c\x06\0\0\0\x03\x03\0\x01\0\0\0\0\0\0\0\x01\x03\x03\0\x01\0\0\0\0\0\0\0\x02\x03\x03\0\x01\0\0\0\0\0\0\0\x03\x03\x03\0\x01\0\0\0\0\0\0\0\x04\x03\x03\0\x01\0\0\0\0\0\0\0\0\x0f\x07\0\xee\x01\0\0\x6c\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x64\0\0\0\x64\0\0\0\xfa\x1b\0\0\xe8\x03\0\0\x90\xff\x0b\xff\xd4\xfe\xd6\xff\xbd\xff\xbd\xff\x53\x58\x37\x37\x37\0\0\0\x5b\x70\x69\x63\x74\x75\x72\x65\x49\x6e\x66\x6f\x5d\x20\x52\x65\x73\x6f\x6c\x75\x74\x69\x6f\x6e\x3d\x31\x20\x5b\x43\x61\x6d\x65\x72\x61\x20\x49\x6e\x66\x6f\x5d\x20\x54\x79\x70\x65\x3d\x53\x58\x37\x37\x37\0\0\0\0\0\0\0\0\0\x4f\x4c\x59\x4d\x50\x55\x53\x20\x44\x49\x47\x49\x54\x41\x4c\x20\x43\x41\x4d\x45\x52\x41\0\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01\x34\x02\x05\x02\x9f\0\0\0\0\xff\0\0\x02\x19\x61\x12\x31\0\0\x05\xe3\0\0\x1c\x20\0\0\x06\xfc\0\0\x1b\xf0\0\0\x1b\xf0\0\0\x07\x10\0\0\x16\x90\0\x64\0\xc7\0\x40\0\x1c\0\0\0\0\0\0\0\0\0\0\x2a\x92\0\0\0\0\x2a\x2e\x12\x03\x10\0\0\0\0\0\0\0\0\0\0\0\x13\x1a\0\0\x3c\0\x0f\x4a\0\0\0\0\0\0\0\0\0\0\0\0\0\x64\x06\xfc\0\0\0\0\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x22\x11\x11\x11\x11\x01\xa4\x03\x7e\x03\xeb\x01\x7c\x02\x05\x02\x1b\x01\xa1\x02\0\x01\x02\xf0\x59\0\x01\x03\x52\0\x16\0\x0d\0\x16\0\x0d\0\x05\0\x0a\0\x01\0\0\0\0\0\x10\0\0\0\x14\0\x01\0\0\0\xc7\x01\x6f\x02\x17\x02\xc0\x03\x68\x01\x03\x01\x34\x02\x05\x02\x9f\0\0\x0c\x2f\x0d\xe1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x88\x88\x01\0\0\xed\x11\xda\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x40\x01\x1a\0\xb8\x02\x4e\0\x0e\x09\x17\x01\x44\x02\x73\x02\xde\x03\x10\x02\xd4\xd0\0\0\xed\x11\0\0\0\x01\x44\x01\xfc\x04\x53\x08\x48\x09\x17\x05\xc1\x02\x56\0\0\x0a\x84\x12\xcc\x19\x8d\x1b\x37\x16\x68\x0b\x90\x04\x38\0\0\x06\xff\x08\x92\x09\x29\x08\x3f\x06\x26\0\0\0\0\0\0\x1b\xa7\x1b\x24\x17\xe3\x12\xea\x0c\xd7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x77\x77\x77\x77\x13\x27\x13\x1f\x13\x1f\x13\x1f\x0d\x18\x05\0\xe1\x07\0\x07\0\0\x03\0\0\0\x0f\0\x69\0\x4f\x76\x59\x03\x03\0\x12\x24\x37\0\x15\x29\x14\x2a\x01\xfb\x01\x83\x01\xee\x02\x32\0\0\x01\x0d\0\x36\0\x6e\x02\x1b\x01\xa1\x12\x24\x14\x2a\x20\x52\0\x04\0\x0a\x04\x03\x6e\x5f\x01\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '840 bytes unknown MakerNote data');
$entry = $ifd0_0->getEntry(37510); // UserComment
$this->assertInstanceOf('lsolesen\pel\PelEntryUserComment', $entry);
$this->assertEquals($entry->getValue(), ' ');
$this->assertEquals($entry->getText(), ' ');
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 2288);
$this->assertEquals($entry->getText(), '2288');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 1712);
$this->assertEquals($entry->getText(), '1712');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41729); // SceneType
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01");
$this->assertEquals($entry->getText(), 'Directly photographed');
$entry = $ifd0_0->getEntry(41985); // CustomRendered
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal process');
$entry = $ifd0_0->getEntry(41986); // ExposureMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto exposure');
$entry = $ifd0_0->getEntry(41987); // WhiteBalance
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto white balance');
$entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 0,
1 => 100
]);
$this->assertEquals($entry->getText(), '0/100');
$entry = $ifd0_0->getEntry(41990); // SceneCaptureType
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Portrait');
$entry = $ifd0_0->getEntry(41991); // GainControl
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41992); // Contrast
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41993); // Saturation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
$entry = $ifd0_0->getEntry(41994); // Sharpness
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 1);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getEntries()), 2);
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'R98');
$this->assertEquals($entry->getText(), 'R98');
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Interoperability Version 1.0');
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 4);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/olympus-c765uz-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,61 @@
README file for PEL Test Images.
Copyright (C) 2004, 2005, 2006 Martin Geisler.
Licensed under the GNU GPL, see COPYING for details.
PEL Test Images
***************
The images contained in this directory are test images collected for
use with PEL: PHP Exif Library. One can download PEL from:
http://github.com/lsolesen/pel/
All images except no-exif.jpg contain Exif information, and the
corresponding PHP files contain SimpleTest (http://simpletest.sf.net/)
unit tests.
To use those files with PEL, first place this directory (the
image-tests directory) under the test directory in an unpacked PEL
source tree. Install SimpleTest using the instructions found in the
README file in the test directory.
Now run the run-tests.php script in the test directory. It should
automatically pickup the new tests.
The images can be used by anybody, but may only be redistributed under
the GNU GPL. See the file COPYING for the details.
Contributing Test Images
************************
If you own a camera model from which there are no test image, then
please contribute one. The image should
* contain as much interesting Exif tags as possible. The camera
should therefore be set to a manual mode, and the settings should be
changed from their defaults,
* have as small a file size as possible, so use a resolution of
640x480 or less, if possible. Also, use the poorest image quality
(the best compression) to reduce the file size.
* come from the camera unaltered. Do not resize the image using an
image manipulation program, for then it is this program that will be
tested, not the camera that took the image,
* be of something which wont protest to be widely published on the
net. Things like a flower, a mountain, or a cat springs to mind,
whereas pictures from a private party are no good,
* be licensed under the GNU GPL as the rest of PEL Test Images, so
that it can be redistributed with it.
Submit your test image(s) by forking the repository found at
http://github.com/lsolesen/pel/
All image contributers will be given full credit in the AUTHORS file
distributed with PEL.

View File

@@ -0,0 +1,369 @@
<?php
/*
* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
*
* Copyright (C) 2005, 2006 Martin Geisler.
*
* This program 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.
*
* This program 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 this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
namespace Pel\Test\imagetests;
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;
use PHPUnit\Framework\TestCase;
class SonyDscV1Test extends TestCase
{
public function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/sony-dsc-v1.jpg');
$exif = $jpeg->getExif();
$this->assertInstanceOf('lsolesen\pel\PelExif', $exif);
$tiff = $exif->getTiff();
$this->assertInstanceOf('lsolesen\pel\PelTiff', $tiff);
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0);
/* Start of IDF $ifd0. */
$this->assertEquals(count($ifd0->getEntries()), 10);
$entry = $ifd0->getEntry(270); // ImageDescription
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), ' ');
$this->assertEquals($entry->getText(), ' ');
$entry = $ifd0->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'SONY');
$this->assertEquals($entry->getText(), 'SONY');
$entry = $ifd0->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'DSC-V1');
$this->assertEquals($entry->getText(), 'DSC-V1');
$entry = $ifd0->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'right - top');
$entry = $ifd0->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd0->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1089482993);
$this->assertEquals($entry->getText(), '2004:07:10 18:09:53');
$entry = $ifd0->getEntry(531); // YCbCrPositioning
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'co-sited');
$entry = $ifd0->getEntry(50341); // PrintIM
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x50\x72\x69\x6e\x74\x49\x4d\0\x30\x32\x35\x30\0\0\x02\0\x02\0\x01\0\0\0\x01\x01\0\0\0\0");
$this->assertEquals($entry->getText(), '(undefined)');
/* Sub IFDs of $ifd0. */
$this->assertEquals(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0);
/* Start of IDF $ifd0_0. */
$this->assertEquals(count($ifd0_0->getEntries()), 26);
$entry = $ifd0_0->getEntry(33434); // ExposureTime
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 10,
1 => 600
]);
$this->assertEquals($entry->getText(), '1/60 sec.');
$entry = $ifd0_0->getEntry(33437); // FNumber
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 32,
1 => 10
]);
$this->assertEquals($entry->getText(), 'f/3.2');
$entry = $ifd0_0->getEntry(34850); // ExposureProgram
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Normal program');
$entry = $ifd0_0->getEntry(34855); // ISOSpeedRatings
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 100);
$this->assertEquals($entry->getText(), '100');
$entry = $ifd0_0->getEntry(36864); // ExifVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 2.2);
$this->assertEquals($entry->getText(), 'Exif Version 2.2');
$entry = $ifd0_0->getEntry(36867); // DateTimeOriginal
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1089482993);
$this->assertEquals($entry->getText(), '2004:07:10 18:09:53');
$entry = $ifd0_0->getEntry(36868); // DateTimeDigitized
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1089482993);
$this->assertEquals($entry->getText(), '2004:07:10 18:09:53');
$entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01\x02\x03\0");
$this->assertEquals($entry->getText(), 'Y Cb Cr -');
$entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 2,
1 => 1
]);
$this->assertEquals($entry->getText(), '2/1');
$entry = $ifd0_0->getEntry(37380); // ExposureBiasValue
$this->assertInstanceOf('lsolesen\pel\PelEntrySRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 7,
1 => 10
]);
$this->assertEquals($entry->getText(), '+0.7');
$entry = $ifd0_0->getEntry(37381); // MaxApertureValue
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 48,
1 => 16
]);
$this->assertEquals($entry->getText(), '48/16');
$entry = $ifd0_0->getEntry(37383); // MeteringMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Center-Weighted Average');
$entry = $ifd0_0->getEntry(37384); // LightSource
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Unknown');
$entry = $ifd0_0->getEntry(37385); // Flash
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 31);
$this->assertEquals($entry->getText(), 'Flash fired, auto mode, return light detected.');
$entry = $ifd0_0->getEntry(37386); // FocalLength
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 139,
1 => 10
]);
$this->assertEquals($entry->getText(), '13.9 mm');
$entry = $ifd0_0->getEntry(37500); // MakerNote
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$expected = "\x53\x4f\x4e\x59\x20\x44\x53\x43\x20\0\0\0\x0c\0\x01\x90\x07\0\x94\0\0\0\x40\x03\0\0\x02\x90\x07\0\xc8\0\0\0\xd4\x03\0\0\x03\x90\x07\0\xc8\0\0\0\x9c\x04\0\0\x04\x90\x07\0\x1a\0\0\0\x64\x05\0\0\x05\x90\x07\0\x78\0\0\0\x7e\x05\0\0\x06\x90\x07\0\xfc\0\0\0\xf6\x05\0\0\x07\x90\x07\0\xc8\0\0\0\xf2\x06\0\0\x08\x90\x07\0\xc8\0\0\0\xba\x07\0\0\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xdf\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\0\0\0\0\0\0\0\x0c\0\0\0\x05\0\x6e\x7e\xa0\0\xe4\x89\x2c\0\xe7\x8f\0\0\0\0\x0c\0\0\0\0\0\0\0\x0c\0\x01\xe7\x41\xff\0\0\0\0\0\x08\x07\x02\x09\xfe\0\x60\x1f\x08\xdf\x5e\xf0\xff\x4a\xfe\0\0\0\0\x4a\x30\0\x88\x1f\x05\x4a\x30\x4a\x88\0\x70\0\0\x70\0\0\x01\xb8\0\x5e\0\x81\0\0\x56\x0d\0\0\0\x63\0\0\xd8\xc4\0\0\xd2\x90\x88\x1f\xbe\0\x70\0\0\xc8\0\xbe\x5e\0\xd8\x6f\0\0\x40\x50\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\x04\0\x1b\0\0\0\x07\0\0\x01\xb8\x08\0\x8a\xb7\0\x74\x91\xf0\0\x8c\x75\x3d\0\0\0\xd8\0\0\0\0\0\0\0\0\0\0\0\0\x05\xc4\0\0\xd3\0\xc3\x74\xd7\x93\xd8\x67\x05\xc4\xd7\x22\x30\x63\0\0\0\0\xd7\xa7\xbe\x21\0\0\0\0\0\0\0\0\0\0\x01\x14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x0e\x08\xe3\0\x7d\0\x28\x8a\x0e\0\x5e\0\0\xa8\0\xbe\xc0\xbe\xc0\xd7\x93\x40\0\0\0\xdc\xdc\x73\x46\0\x92\0\xb7\0\x23\0\x23\0\x47\0\x82\0\x06\0\x55\xef\x10\x24\x31\xef\xc3\x79\x73\xef\x10\x79\x8a\x79\x05\xc4\xef\x5b\xc5\x18\xc5\x18\x7d\xa5\x88\xb7\xcf\0\0\x01\x69\0\0\0\0\0\0\0\0\xff\0\0\xf1\0\x07\0\x47\xff\0\x01\x15\0\x6a\0\x20\x23\0\x5e\0\0\0\x56\0\x08\xdd\x01\xc5\x01\0\x01\0\x04\x80\x1b\xf2\x45\xdd\x38\x54\0\x69\x24\xdc\x0c\x63\xf0\xde\xec\x23\x28\x47\xf0\xa8\x92\x45\xef\x21\xc5\x49\x58\x2f\0\xc3\x46\xfe\x59\x5a\x9f\xfe\0\x07\xf3\x52\xa0\x6e\x51\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\xbd\x20\x08\x1b\0\x01\xdc\xdc\xbc\x5f\x10\0\0\x08\xec\x08\xe7\x08\x04\x08\x51\0\xdc\0\xe3\0\xe3\0\xc2\0\0\0\0\0\0\0\0\x01\x01\0\0\0\0\0\x7d\0\0\0\0\0\x7b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\x01\0\0\0\0\0\x01\0\x01\0\x08\0\x01\0\x01\xe5\x91\x51\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\xff\0\xff\0\0\0\0\0\0\0\0\xb3\xe5\0\0\xff\xff\0\0\xcd\x95\x51\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x7d\0\x40\0\x1b\0\0\0\x01\xd8\x2b\xd8\x47\x5e\xa7\xbb\x9e\x0e\x8b\x20\x08\xa0\xfd\xd8\xf4\x5e\x2b\x56\x69\x88\xe8\xd8\xaa\xb6\x60\x6a\x98\x0e\x53\x56\x8e\x56\x8d\x05\xe1\xd8\x5d\x20\xcc\xd3\x58\x5e\xb6\x04\xb7\xe7\xe9\xcd\x57\x7d\x2c\xd7\x24\x5d\xbc\x5e\xd3\x04\xdc\xd8\x8f\xea\x4f\x7d\x6e\x30\x28\xd3\x4b\x7d\xf7\xe7\xf8\x7d\x09\x8a\x26\x7d\xc4\x88\x24\xa0\x9e\x40\x94\x7d\xf1\x7d\x95\x5e\x46\x40\xd3\x70\x44\xbe\xfb\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x08\0\0\0\0\0\x1b\0\x1b\0\0\0\x7d\0\x5e\0\0\0\0\0\x08\0\x40\0\0\0\xd8\0\xe7\0\0\0\0\0\x08\0\x40\0\0\0\x0e\0\x0e\0\0\0\0\0\x08\0\x7d\0\0\0\xe7\0\x08\0\x7d\0\x1b\0\0\0\x01\0\0\0\xd8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x40\x43\xd8\xe0\x5e\xd1\x04\xf7\x8a\xde\x30\xf4\x20\x39\x05\x45\x05\xce\xb6\x31\x88\xbf\x30\x24\x30\x77\x30\xb7\x88\x65\0\xa3\x7d\xdd\xd8\xd6\x0e\x43\xea\x11\x69\x6c\x81\xb9\xec\x45\x28\x13\xb6\xe6\x20\xdc\xbe\x5b\x81\x3e\x0c\xc3\xec\x9e\x6c\x35\0\0\0\0\x08\x4a\x08\x22\x1b\xe2\x40\x9e\x5e\x4b\xb6\x8b\x05\xa0\xd8\x41\x5e\xa9\x56\xdd\x8a\x43\x69\x80\x69\x5b\x70\xe0\xea\x88\0\xa3\x08\x8d\x1b\xc4\x1b\xa8\x7d\x57\x56\xa7\x69\x8c\x88\xe6\x69\x94\x56\xa9\x8a\x08\xb6\xba\x69\x23\x69\xba\x88\x94\xbe\x81\0\0\0\0\x40\x43\x7d\x40\x7d\x54\xd8\x54\xe7\xea\x70\xc7\x05\x07\x5e\xe1\x0e\xa8\x56\xa4\x05\x80\x70\xc7\x70\xc7\x05\x80\x56\x0d\0\xa3\x30\x63\xbe\xd8\xbe\x5b\xbe\x9e\xbe\x21\xd7\x96\xd7\x86\xd7\x22\xbe\x21\xd7\xb6\xd7\xef\xd7\x74\xd7\xd4\xd7\xb3\xd7\xa7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$this->assertEquals($entry->getValue(), $expected);
$this->assertEquals($entry->getText(), '1504 bytes unknown MakerNote data');
$entry = $ifd0_0->getEntry(40960); // FlashPixVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'FlashPix Version 1.0');
$entry = $ifd0_0->getEntry(40961); // ColorSpace
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'sRGB');
$entry = $ifd0_0->getEntry(40962); // PixelXDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 640);
$this->assertEquals($entry->getText(), '640');
$entry = $ifd0_0->getEntry(40963); // PixelYDimension
$this->assertInstanceOf('lsolesen\pel\PelEntryLong', $entry);
$this->assertEquals($entry->getValue(), 480);
$this->assertEquals($entry->getText(), '480');
$entry = $ifd0_0->getEntry(41728); // FileSource
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x03");
$this->assertEquals($entry->getText(), 'DSC');
$entry = $ifd0_0->getEntry(41729); // SceneType
$this->assertInstanceOf('lsolesen\pel\PelEntryUndefined', $entry);
$this->assertEquals($entry->getValue(), "\x01");
$this->assertEquals($entry->getText(), 'Directly photographed');
$entry = $ifd0_0->getEntry(41985); // CustomRendered
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Normal process');
$entry = $ifd0_0->getEntry(41986); // ExposureMode
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Manual exposure');
$entry = $ifd0_0->getEntry(41987); // WhiteBalance
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Auto white balance');
$entry = $ifd0_0->getEntry(41990); // SceneCaptureType
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 0);
$this->assertEquals($entry->getText(), 'Standard');
/* Sub IFDs of $ifd0_0. */
$this->assertEquals(count($ifd0_0->getSubIfds()), 1);
$ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd0_0_0);
/* Start of IDF $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getEntries()), 2);
$entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'R98');
$this->assertEquals($entry->getText(), 'R98');
$entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion
$this->assertInstanceOf('lsolesen\pel\PelEntryVersion', $entry);
$this->assertEquals($entry->getValue(), 1);
$this->assertEquals($entry->getText(), 'Interoperability Version 1.0');
/* Sub IFDs of $ifd0_0_0. */
$this->assertEquals(count($ifd0_0_0->getSubIfds()), 0);
$this->assertEquals($ifd0_0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_0_1 = $ifd0_0_0->getNextIfd();
$this->assertNull($ifd0_0_1);
/* End of IFD $ifd0_0_0. */
$this->assertEquals($ifd0_0->getThumbnailData(), '');
/* Next IFD. */
$ifd0_1 = $ifd0_0->getNextIfd();
$this->assertNull($ifd0_1);
/* End of IFD $ifd0_0. */
$this->assertEquals($ifd0->getThumbnailData(), '');
/* Next IFD. */
$ifd1 = $ifd0->getNextIfd();
$this->assertInstanceOf('lsolesen\pel\PelIfd', $ifd1);
/* End of IFD $ifd0. */
/* Start of IDF $ifd1. */
$this->assertEquals(count($ifd1->getEntries()), 8);
$entry = $ifd1->getEntry(259); // Compression
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'JPEG compression');
$entry = $ifd1->getEntry(271); // Make
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'SONY');
$this->assertEquals($entry->getText(), 'SONY');
$entry = $ifd1->getEntry(272); // Model
$this->assertInstanceOf('lsolesen\pel\PelEntryAscii', $entry);
$this->assertEquals($entry->getValue(), 'DSC-V1');
$this->assertEquals($entry->getText(), 'DSC-V1');
$entry = $ifd1->getEntry(274); // Orientation
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 6);
$this->assertEquals($entry->getText(), 'right - top');
$entry = $ifd1->getEntry(282); // XResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(283); // YResolution
$this->assertInstanceOf('lsolesen\pel\PelEntryRational', $entry);
$this->assertEquals($entry->getValue(), [
0 => 72,
1 => 1
]);
$this->assertEquals($entry->getText(), '72/1');
$entry = $ifd1->getEntry(296); // ResolutionUnit
$this->assertInstanceOf('lsolesen\pel\PelEntryShort', $entry);
$this->assertEquals($entry->getValue(), 2);
$this->assertEquals($entry->getText(), 'Inch');
$entry = $ifd1->getEntry(306); // DateTime
$this->assertInstanceOf('lsolesen\pel\PelEntryTime', $entry);
$this->assertEquals($entry->getValue(), 1089482993);
$this->assertEquals($entry->getText(), '2004:07:10 18:09:53');
/* Sub IFDs of $ifd1. */
$this->assertEquals(count($ifd1->getSubIfds()), 0);
$thumb_data = file_get_contents(dirname(__FILE__) . '/sony-dsc-v1-thumb.jpg');
$this->assertEquals($ifd1->getThumbnailData(), $thumb_data);
/* Next IFD. */
$ifd2 = $ifd1->getNextIfd();
$this->assertNull($ifd2);
/* End of IFD $ifd1. */
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB