diff --git a/Gruntfile.js b/Gruntfile.js
index e2169bd..ed2879d 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -47,8 +47,8 @@ module.exports = function(grunt) {
options: {
bin : 'vendor/bin/phpunit',
- configuration : 'phpunit.xml.dist',
- group : 'ImageMetadataReader.Dotnet256x256AlphaPaletteTest'
+ configuration : 'phpunit.xml.dist'//,
+ //group : 'ImageMetadataReader.FujiFilmFinePixS1ProTest'
}
}, /* PHPUnit Task */
diff --git a/README.md b/README.md
index 03a426a..ad2f7d5 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,31 @@ Metadata metadata = ImageMetadataReader.readMetadata(imagePath);
## Installation
+The easiest way to install the library is to use [composer](https://getcomposer.org/ "composer") and define the
+following dependency inside your `composer.json` file :
+
+```json
+{
+ "require": {
+ "gomoob/php-metadata-extractor": "~2.9"
+ }
+}
+```
+
+Please also note that because the library is a wrapper around a Java library the `java` executable must be available
+in your `PATH` variable.
+
+## Versioning
+
+To easier version identification the version of `php-metadata-extractor` will always be aligned with the version
+of the Java `metadata-extractor`.
+
+Stable versions of `php-metadata-extrator` will be equal to `X.Y.Z-N` where `N` represents a patch number
+associated to `php-metadata-extractor`.
+
+Unstable or uncomplete versions of `php-metadata-extractor` will be equal to `X.Y.Z-alpha.N` or
+`X.Y.Z-beta.N`.
+
## About Gomoob
At [Gomoob](https://www.gomoob.com "Gomoob") we build high quality software with awesome Open Source frameworks
diff --git a/composer.json b/composer.json
index ac7c5f5..f849b33 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name" : "gomoob/php-metadata-extractor",
"description" : "PHP wrapper to easily call the Java metadata-extrator library.",
- "version" : "1.0.0",
+ "version" : "2.9.1-alpha.1",
"license" : "MIT",
"type" : "library",
"keywords" : [
diff --git a/package.json b/package.json
index eff6932..7a28f4f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gomoob-php-metadata-extractor",
- "version": "1.0.0",
+ "version": "2.9.1-alpha.1",
"license": "MIT",
"repository" : {
"type" : "git",
diff --git a/src/main/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader.php b/src/main/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader.php
index f77d444..12ab5c6 100644
--- a/src/main/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader.php
+++ b/src/main/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader.php
@@ -2,10 +2,10 @@
/**
* gomoob/php-metadata-extractor
-*
-* @copyright Copyright (c) 2016, GOMOOB SARL (http://gomoob.com)
-* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE.md file)
-*/
+ *
+ * @copyright Copyright (c) 2016, GOMOOB SARL (http://gomoob.com)
+ * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE.md file)
+ */
namespace Gomoob\MetadataExtractor\Imaging;
use Gomoob\BinaryDriver\MetadataExtractorDriver;
@@ -32,6 +32,7 @@
use Gomoob\MetadataExtractor\Metadata\Exif\GpsDirectory;
use Gomoob\MetadataExtractor\Lang\Rational;
use Gomoob\MetadataExtractor\Metadata\Png\PngDirectory;
+use Gomoob\MetadataExtractor\Metadata\Gif\GifHeaderDirectory;
/**
* Reads metadata from any supported file format.
@@ -60,6 +61,15 @@
*/
class ImageMetadataReader
{
+ /**
+ * The last console output, this property is only defined for the PHP version of the library. The PHP version of
+ * the library parses the console output of the Java `metadata-extractor` library, ths variable contains the last
+ * console output.
+ *
+ * @var string
+ */
+ private static $lastOutput;
+
/**
* The {@link MetadataExtractorDriver} driver used to manage calls to the `metadata-extractor` library.
*
@@ -67,19 +77,29 @@ class ImageMetadataReader
*/
private $metadataExtractorDriver;
+ /**
+ * Gets the last console output.
+ *
+ * @return string the last console output.
+ */
+ public static function getLastOutput()
+ {
+ return static::$lastOutput;
+ }
+
public static function readMetadata($file)
{
$metadata = new Metadata();
$metadataExtractorDriver = MetadataExtractorDriver::create();
- $output = $metadataExtractorDriver->command(
+ static::$lastOutput = $metadataExtractorDriver->command(
[
$file
]
);
// Parse each line of the output
- foreach (explode(PHP_EOL, $output) as $line) {
+ foreach (explode(PHP_EOL, static::$lastOutput) as $line) {
$trimedLine = trim($line);
// We ignore empty lines, metadata-extractor outputs empty line to have a human readable console output but
@@ -438,6 +458,30 @@ private static function addTagToDirectory(Directory $directory, $tagLine)
default:
// TODO: Error
}
+ } elseif ($directory instanceof GifHeaderDirectory) {
+ switch ($nameAndDescription[0]) {
+ case 'GIF Format Version':
+ break;
+ case 'Image Height':
+ $directory->setInt(GifHeaderDirectory::TAG_IMAGE_HEIGHT, intval($nameAndDescription[1]));
+ break;
+ case 'Image Width':
+ $directory->setInt(GifHeaderDirectory::TAG_IMAGE_WIDTH, intval($nameAndDescription[1]));
+ break;
+ case 'Color Table Size':
+ break;
+ case 'Is Color Table Sorted':
+ break;
+ case 'Bits per Pixel':
+ break;
+ case 'Has Global Color Table':
+ break;
+ case 'Background Color Index':
+ break;
+ case 'Pixel Aspect Ratio':
+ break;
+ default:
+ }
} elseif ($directory instanceof JfifDirectory) {
switch ($nameAndDescription[0]) {
case 'Version':
@@ -533,9 +577,52 @@ private static function addTagToDirectory(Directory $directory, $tagLine)
// TODO: Exception
}
} elseif ($directory instanceof PngDirectory) {
- // var_dump($tagLine);
- // var_dump($nameAndDescription[0]);
- // var_dump($nameAndDescription[1]);
+// var_dump($tagLine);
+// var_dump($nameAndDescription);
+ switch ($nameAndDescription[0]) {
+ case 'Image Height':
+ $directory->setInt(PngDirectory::TAG_IMAGE_HEIGHT, intval($nameAndDescription[1]));
+ break;
+ case 'Image Width':
+ $directory->setInt(PngDirectory::TAG_IMAGE_WIDTH, intval($nameAndDescription[1]));
+ break;
+ case 'Bits Per Sample':
+ break;
+ case 'Color Type':
+ break;
+ case 'Compression Type':
+ break;
+ case 'Filter Method':
+ break;
+ case 'Interlace Method':
+ break;
+ case 'Palette Size':
+ break;
+ case 'Palette Has Transparency':
+ break;
+ case 'sRGB Rendering Intent':
+ break;
+ case 'Image Gamma':
+ break;
+ case 'ICC Profile Name':
+ break;
+ case 'Textual Data':
+ break;
+ case 'Last Modification Time':
+ break;
+ case 'Background Color':
+ break;
+ case 'Pixels Per Unit X':
+ break;
+ case 'Pixels Per Unit Y':
+ break;
+ case 'Unit Specifier':
+ break;
+ case 'Significant Bits':
+ break;
+ default:
+ break;
+ }
}
}
@@ -605,6 +692,9 @@ private static function createDirectoryWithName($directoryName)
case 'File':
$directory = new FileMetadataDirectory();
break;
+ case 'GIF Header':
+ $directory = new GifHeaderDirectory();
+ break;
case 'GPS':
$directory = new GpsDirectory();
break;
diff --git a/src/main/php/Gomoob/MetadataExtractor/Metadata/Directory.php b/src/main/php/Gomoob/MetadataExtractor/Metadata/Directory.php
index 4e88b9e..a16ecd2 100644
--- a/src/main/php/Gomoob/MetadataExtractor/Metadata/Directory.php
+++ b/src/main/php/Gomoob/MetadataExtractor/Metadata/Directory.php
@@ -62,6 +62,81 @@ public function getDescription($tagType)
return $this->descriptor.getDescription($tagType);
}
+
+ /**
+ * Returns the specified tag's value as an int, if possible. Every attempt to represent the tag's value as an int
+ * is taken.
+ *
+ * Here is a list of the action taken depending upon the tag's original type:
+ * * int - Return unchanged.
+ * * Number - Return an int value (real numbers are truncated).
+ * * Rational - Truncate any fractional part and returns remaining int.
+ * * String - Attempt to parse string as an int. If this fails, convert the char[] to an int (using shifts and
+ * OR).
+ * * Rational[] - Return int value of first item in array.
+ * * byte[] - Return int value of first item in array.
+ * * int[] - Return int value of first item in array.
+ *
+ * @throws MetadataException if no value exists for tagType or if it cannot be converted to an int.
+ */
+ public function getInt($tagType)
+ {
+ $integer = $this->getInteger($tagType);
+
+ if ($integer !== null) {
+ return $integer;
+ }
+
+ $o = $this->getObject($tagType);
+
+ if ($o === null) {
+ throw new MetadataException(
+ "Tag '" . $this->getTagName($tagType) . "' has not been set -- check using containsTag() first"
+ );
+ }
+
+ throw new MetadataException(
+ "Tag '" . $tagType . "' cannot be converted to int. It is of type '" . $o->getClass() . "'."
+ );
+ }
+
+ /**
+ * Returns the specified tag's value as an Integer, if possible. Every attempt to represent the tag's value as an
+ * Integer is taken.
+ *
+ * Here is a list of the action taken depending upon the tag's original type:
+ * * int - Return unchanged
+ * * Number - Return an int value (real numbers are truncated)
+ * * Rational - Truncate any fractional part and returns remaining int
+ * * String - Attempt to parse string as an int. If this fails, convert the char[] to an int (using shifts and OR)
+ * * Rational[] - Return int value of first item in array if length > 0
+ * * byte[] - Return int value of first item in array if length > 0
+ * * int[] - Return int value of first item in array if length > 0
+ *
+ * If the value is not found or cannot be converted to int, null
is returned.
+ */
+ public function getInteger($tagType)
+ {
+ // FIXME: This method has to be reviewed
+
+ $o = $this->getObject($tagType);
+
+ if ($o === null) {
+ return null;
+ }
+
+ if (is_int($o)) {
+ return $o;
+ } elseif (is_string($o)) {
+ return intval($o);
+ } elseif (is_array($o)) {
+ if (count($o) === 1) {
+ return intval($o[0]);
+ }
+ }
+
+ return null;
+ }
/**
* Provides the name of the directory, for display purposes. E.g. Exif
diff --git a/src/main/php/Gomoob/MetadataExtractor/Metadata/Gif/GifHeaderDescriptor.php b/src/main/php/Gomoob/MetadataExtractor/Metadata/Gif/GifHeaderDescriptor.php
new file mode 100644
index 0000000..5562da9
--- /dev/null
+++ b/src/main/php/Gomoob/MetadataExtractor/Metadata/Gif/GifHeaderDescriptor.php
@@ -0,0 +1,19 @@
+ "GIF Format Version",
+ self::TAG_IMAGE_HEIGHT => "Image Height",
+ self::TAG_IMAGE_WIDTH => "Image Width",
+ self::TAG_COLOR_TABLE_SIZE => "Color Table Size",
+ self::TAG_IS_COLOR_TABLE_SORTED => "Is Color Table Sorted",
+ self::TAG_BITS_PER_PIXEL => "Bits per Pixel",
+ self::TAG_HAS_GLOBAL_COLOR_TABLE => "Has Global Color Table",
+ self::TAG_BACKGROUND_COLOR_INDEX => "Background Color Index",
+ self::TAG_PIXEL_ASPECT_RATIO => "Pixel Aspect Ratio"
+ ];
+
+ public function __construct()
+ {
+ $this->setDescriptor(new GifHeaderDescriptor($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getName()
+ {
+ return 'GIF Header';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getTagNameMap()
+ {
+ return static::$tagNameMap;
+ }
+}
diff --git a/src/main/php/Gomoob/MetadataExtractor/Metadata/Icc/IccDirectory.php b/src/main/php/Gomoob/MetadataExtractor/Metadata/Icc/IccDirectory.php
index 081c131..ae19eb0 100644
--- a/src/main/php/Gomoob/MetadataExtractor/Metadata/Icc/IccDirectory.php
+++ b/src/main/php/Gomoob/MetadataExtractor/Metadata/Icc/IccDirectory.php
@@ -89,71 +89,71 @@ class IccDirectory extends Directory
const TAG_APPLE_MULTI_LANGUAGE_PROFILE_NAME = 0x6473636d;
private static $tagNameMap = [
- self::TAG_PROFILE_BYTE_COUNT => "Profile Size",
- self::TAG_CMM_TYPE => "CMM Type",
- self::TAG_PROFILE_VERSION => "Version",
- self::TAG_PROFILE_CLASS => "Class",
- self::TAG_COLOR_SPACE => "Color space",
- self::TAG_PROFILE_CONNECTION_SPACE => "Profile Connection Space",
- self::TAG_PROFILE_DATETIME => "Profile Date/Time",
- self::TAG_SIGNATURE => "Signature",
- self::TAG_PLATFORM => "Primary Platform",
- self::TAG_CMM_FLAGS => "CMM Flags",
- self::TAG_DEVICE_MAKE => "Device manufacturer",
- self::TAG_DEVICE_MODEL => "Device model",
- self::TAG_DEVICE_ATTR => "Device attributes",
- self::TAG_RENDERING_INTENT => "Rendering Intent",
- self::TAG_XYZ_VALUES => "XYZ values",
- self::TAG_PROFILE_CREATOR => "Profile Creator",
- self::TAG_TAG_COUNT => "Tag Count",
- self::TAG_TAG_A2B0 => "AToB 0",
- self::TAG_TAG_A2B1 => "AToB 1",
- self::TAG_TAG_A2B2 => "AToB 2",
- self::TAG_TAG_bXYZ => "Blue Colorant",
- self::TAG_TAG_bTRC => "Blue TRC",
- self::TAG_TAG_B2A0 => "BToA 0",
- self::TAG_TAG_B2A1 => "BToA 1",
- self::TAG_TAG_B2A2 => "BToA 2",
- self::TAG_TAG_calt => "Calibration Date/Time",
- self::TAG_TAG_targ => "Char Target",
- self::TAG_TAG_chad => "Chromatic Adaptation",
- self::TAG_TAG_chrm => "Chromaticity",
- self::TAG_TAG_cprt => "Copyright",
- self::TAG_TAG_crdi => "CrdInfo",
- self::TAG_TAG_dmnd => "Device Mfg Description",
- self::TAG_TAG_dmdd => "Device Model Description",
- self::TAG_TAG_devs => "Device Settings",
- self::TAG_TAG_gamt => "Gamut",
- self::TAG_TAG_kTRC => "Gray TRC",
- self::TAG_TAG_gXYZ => "Green Colorant",
- self::TAG_TAG_gTRC => "Green TRC",
- self::TAG_TAG_lumi => "Luminance",
- self::TAG_TAG_meas => "Measurement",
- self::TAG_TAG_bkpt => "Media Black Point",
- self::TAG_TAG_wtpt => "Media White Point",
- self::TAG_TAG_ncol => "Named Color",
- self::TAG_TAG_ncl2 => "Named Color 2",
- self::TAG_TAG_resp => "Output Response",
- self::TAG_TAG_pre0 => "Preview 0",
- self::TAG_TAG_pre1 => "Preview 1",
- self::TAG_TAG_pre2 => "Preview 2",
- self::TAG_TAG_desc => "Profile Description",
- self::TAG_TAG_pseq => "Profile Sequence Description",
- self::TAG_TAG_psd0 => "Ps2 CRD 0",
- self::TAG_TAG_psd1 => "Ps2 CRD 1",
- self::TAG_TAG_psd2 => "Ps2 CRD 2",
- self::TAG_TAG_psd3 => "Ps2 CRD 3",
- self::TAG_TAG_ps2s => "Ps2 CSA",
- self::TAG_TAG_ps2i => "Ps2 Rendering Intent",
- self::TAG_TAG_rXYZ => "Red Colorant",
- self::TAG_TAG_rTRC => "Red TRC",
- self::TAG_TAG_scrd => "Screening Desc",
- self::TAG_TAG_scrn => "Screening",
- self::TAG_TAG_tech => "Technology",
- self::TAG_TAG_bfd => "Ucrbg",
- self::TAG_TAG_vued => "Viewing Conditions Description",
- self::TAG_TAG_view => "Viewing Conditions",
- self::TAG_APPLE_MULTI_LANGUAGE_PROFILE_NAME => "Apple Multi-language Profile Name"
+ self::TAG_PROFILE_BYTE_COUNT => "Profile Size",
+ self::TAG_CMM_TYPE => "CMM Type",
+ self::TAG_PROFILE_VERSION => "Version",
+ self::TAG_PROFILE_CLASS => "Class",
+ self::TAG_COLOR_SPACE => "Color space",
+ self::TAG_PROFILE_CONNECTION_SPACE => "Profile Connection Space",
+ self::TAG_PROFILE_DATETIME => "Profile Date/Time",
+ self::TAG_SIGNATURE => "Signature",
+ self::TAG_PLATFORM => "Primary Platform",
+ self::TAG_CMM_FLAGS => "CMM Flags",
+ self::TAG_DEVICE_MAKE => "Device manufacturer",
+ self::TAG_DEVICE_MODEL => "Device model",
+ self::TAG_DEVICE_ATTR => "Device attributes",
+ self::TAG_RENDERING_INTENT => "Rendering Intent",
+ self::TAG_XYZ_VALUES => "XYZ values",
+ self::TAG_PROFILE_CREATOR => "Profile Creator",
+ self::TAG_TAG_COUNT => "Tag Count",
+ self::TAG_TAG_A2B0 => "AToB 0",
+ self::TAG_TAG_A2B1 => "AToB 1",
+ self::TAG_TAG_A2B2 => "AToB 2",
+ self::TAG_TAG_bXYZ => "Blue Colorant",
+ self::TAG_TAG_bTRC => "Blue TRC",
+ self::TAG_TAG_B2A0 => "BToA 0",
+ self::TAG_TAG_B2A1 => "BToA 1",
+ self::TAG_TAG_B2A2 => "BToA 2",
+ self::TAG_TAG_calt => "Calibration Date/Time",
+ self::TAG_TAG_targ => "Char Target",
+ self::TAG_TAG_chad => "Chromatic Adaptation",
+ self::TAG_TAG_chrm => "Chromaticity",
+ self::TAG_TAG_cprt => "Copyright",
+ self::TAG_TAG_crdi => "CrdInfo",
+ self::TAG_TAG_dmnd => "Device Mfg Description",
+ self::TAG_TAG_dmdd => "Device Model Description",
+ self::TAG_TAG_devs => "Device Settings",
+ self::TAG_TAG_gamt => "Gamut",
+ self::TAG_TAG_kTRC => "Gray TRC",
+ self::TAG_TAG_gXYZ => "Green Colorant",
+ self::TAG_TAG_gTRC => "Green TRC",
+ self::TAG_TAG_lumi => "Luminance",
+ self::TAG_TAG_meas => "Measurement",
+ self::TAG_TAG_bkpt => "Media Black Point",
+ self::TAG_TAG_wtpt => "Media White Point",
+ self::TAG_TAG_ncol => "Named Color",
+ self::TAG_TAG_ncl2 => "Named Color 2",
+ self::TAG_TAG_resp => "Output Response",
+ self::TAG_TAG_pre0 => "Preview 0",
+ self::TAG_TAG_pre1 => "Preview 1",
+ self::TAG_TAG_pre2 => "Preview 2",
+ self::TAG_TAG_desc => "Profile Description",
+ self::TAG_TAG_pseq => "Profile Sequence Description",
+ self::TAG_TAG_psd0 => "Ps2 CRD 0",
+ self::TAG_TAG_psd1 => "Ps2 CRD 1",
+ self::TAG_TAG_psd2 => "Ps2 CRD 2",
+ self::TAG_TAG_psd3 => "Ps2 CRD 3",
+ self::TAG_TAG_ps2s => "Ps2 CSA",
+ self::TAG_TAG_ps2i => "Ps2 Rendering Intent",
+ self::TAG_TAG_rXYZ => "Red Colorant",
+ self::TAG_TAG_rTRC => "Red TRC",
+ self::TAG_TAG_scrd => "Screening Desc",
+ self::TAG_TAG_scrn => "Screening",
+ self::TAG_TAG_tech => "Technology",
+ self::TAG_TAG_bfd => "Ucrbg",
+ self::TAG_TAG_vued => "Viewing Conditions Description",
+ self::TAG_TAG_view => "Viewing Conditions",
+ self::TAG_APPLE_MULTI_LANGUAGE_PROFILE_NAME => "Apple Multi-language Profile Name"
];
public function __construct()
diff --git a/src/main/php/Gomoob/MetadataExtractor/Metadata/MetadataException.php b/src/main/php/Gomoob/MetadataExtractor/Metadata/MetadataException.php
new file mode 100644
index 0000000..9e23d85
--- /dev/null
+++ b/src/main/php/Gomoob/MetadataExtractor/Metadata/MetadataException.php
@@ -0,0 +1,20 @@
+assertInstanceOf(PngDirectory::class, $directory);
$this->assertSame('PNG-IHDR', $directory->getName());
- /*
- $rational = $directory->getRational(ExifIFD0Directory::TAG_X_RESOLUTION);
- $this->assertSame(300, $rational->getNumerator());
- $this->assertSame(1, $rational->getDenominator());
+ $this->assertSame(256, $directory->getInt(PngDirectory::TAG_IMAGE_WIDTH));
+ $this->assertSame(256, $directory->getInt(PngDirectory::TAG_IMAGE_HEIGHT));
- $rational = $directory->getRational(ExifIFD0Directory::TAG_Y_RESOLUTION);
- $this->assertSame(300, $rational->getNumerator());
- $this->assertSame(1, $rational->getDenominator());
- */
-
// Checks 'PNG-sRGB' directory
$directory = $metadata->getDirectories()[1];
$this->assertInstanceOf(PngDirectory::class, $directory);
diff --git a/src/test/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader/FujiFilmFinePixS1ProTest.php b/src/test/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader/FujiFilmFinePixS1ProTest.php
index f5c5ead..7f6a33e 100644
--- a/src/test/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader/FujiFilmFinePixS1ProTest.php
+++ b/src/test/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader/FujiFilmFinePixS1ProTest.php
@@ -9,6 +9,17 @@
use PHPUnit\Framework\TestCase;
use Gomoob\MetadataExtractor\Metadata\Exif\ExifIFD0Directory;
+use Gomoob\MetadataExtractor\Metadata\Jpeg\JpegDirectory;
+use Gomoob\MetadataExtractor\Metadata\Jfif\JfifDirectory;
+use Gomoob\MetadataExtractor\Metadata\Exif\ExifSubIFDDirectory;
+use Gomoob\MetadataExtractor\Metadata\Exif\GpsDirectory;
+use Gomoob\MetadataExtractor\Metadata\Exif\ExifThumbnailDirectory;
+use Gomoob\MetadataExtractor\Metadata\Xmp\XmpDirectory;
+use Gomoob\MetadataExtractor\Metadata\Icc\IccDirectory;
+use Gomoob\MetadataExtractor\Metadata\Photoshop\PhotoshopDirectory;
+use Gomoob\MetadataExtractor\Metadata\Iptc\IptcDirectory;
+use Gomoob\MetadataExtractor\Metadata\Adobe\AdobeJpegDirectory;
+use Gomoob\MetadataExtractor\Metadata\File\FileMetadataDirectory;
/**
* Test case used to test the {@link ImageMetadataReader} class with the `Nikon E990.jpg` test file.
@@ -26,7 +37,18 @@ public function testReadMetadata()
$metadata = ImageMetadataReader::readMetadata(
realpath(TEST_RESOURCES_DIRECTORY . '/FujiFilm FinePixS1Pro.jpg')
);
+
+ // Checks 'JPEG' directory
+ $directory = $metadata->getDirectories()[0];
+ $this->assertInstanceOf(JpegDirectory::class, $directory);
+
+ $this->assertSame(600, $directory->getInt(JpegDirectory::TAG_IMAGE_WIDTH));
+ $this->assertSame(400, $directory->getInt(JpegDirectory::TAG_IMAGE_HEIGHT));
+ // Checks 'JFIF' directory
+ $directory = $metadata->getDirectories()[1];
+ $this->assertInstanceOf(JfifDirectory::class, $directory);
+
// Checks 'Exif IFD0' directory
$directory = $metadata->getDirectories()[2];
$this->assertInstanceOf(ExifIFD0Directory::class, $directory);
@@ -38,6 +60,42 @@ public function testReadMetadata()
$rational = $directory->getRational(ExifIFD0Directory::TAG_Y_RESOLUTION);
$this->assertSame(300, $rational->getNumerator());
$this->assertSame(1, $rational->getDenominator());
+
+ // Checks 'Exif SubIFD' directory
+ $directory = $metadata->getDirectories()[3];
+ $this->assertInstanceOf(ExifSubIFDDirectory::class, $directory);
+
+ // Checks 'GPS' directory
+ $directory = $metadata->getDirectories()[4];
+ $this->assertInstanceOf(GpsDirectory::class, $directory);
+
+ // Checks 'Exif Thumbnail' directory
+ $directory = $metadata->getDirectories()[5];
+ $this->assertInstanceOf(ExifThumbnailDirectory::class, $directory);
+
+ // Checks 'XMP' directory
+ $directory = $metadata->getDirectories()[6];
+ $this->assertInstanceOf(XmpDirectory::class, $directory);
+
+ // Checks 'ICC Profile' directory
+ $directory = $metadata->getDirectories()[7];
+ $this->assertInstanceOf(IccDirectory::class, $directory);
+
+ // Checks 'Photoshop' directory
+ $directory = $metadata->getDirectories()[8];
+ $this->assertInstanceOf(PhotoshopDirectory::class, $directory);
+
+ // Checks 'IPTC' directory
+ $directory = $metadata->getDirectories()[9];
+ $this->assertInstanceOf(IptcDirectory::class, $directory);
+
+ // Checks 'Adobe JPEG' directory
+ $directory = $metadata->getDirectories()[10];
+ $this->assertInstanceOf(AdobeJpegDirectory::class, $directory);
+
+ // Checks 'File' directory
+ $directory = $metadata->getDirectories()[11];
+ $this->assertInstanceOf(FileMetadataDirectory::class, $directory);
// TODO: Continue testing
}
diff --git a/src/test/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader/MsPaint10x10Test.php b/src/test/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader/MsPaint10x10Test.php
new file mode 100644
index 0000000..4d3ee87
--- /dev/null
+++ b/src/test/php/Gomoob/MetadataExtractor/Imaging/ImageMetadataReader/MsPaint10x10Test.php
@@ -0,0 +1,45 @@
+getDirectories()[0];
+ $this->assertInstanceOf(GifHeaderDirectory::class, $directory);
+
+ $this->assertSame(10, $directory->getInt(GifHeaderDirectory::TAG_IMAGE_WIDTH));
+ $this->assertSame(10, $directory->getInt(GifHeaderDirectory::TAG_IMAGE_HEIGHT));
+
+ // Checks 'File' directory
+ $directory = $metadata->getDirectories()[1];
+ $this->assertInstanceOf(FileMetadataDirectory::class, $directory);
+
+ // TODO: Continue testing
+ }
+}