Skip to content

Commit

Permalink
Continue implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaillard committed Aug 8, 2016
1 parent 562ff51 commit 5e5932a
Show file tree
Hide file tree
Showing 6 changed files with 784 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
*/
namespace Gomoob\MetadataExtractor\Imaging;

use Gomoob\MetadataExtractor\Metadata\Metadata;
use Gomoob\BinaryDriver\MetadataExtractorDriver;

use Gomoob\MetadataExtractor\Metadata\Metadata;

use Gomoob\MetadataExtractor\Metadata\Directory;
use Gomoob\MetadataExtractor\Metadata\File\FileMetadataDirectory;
use Gomoob\MetadataExtractor\Metadata\Jpeg\JpegComponent;
use Gomoob\MetadataExtractor\Metadata\Jpeg\JpegDirectory;
use Gomoob\MetadataExtractor\Metadata\Jfif\JfifDirectory;
use Gomoob\MetadataExtractor\Metadata\Exif\ExifIFD0Directory;
use Gomoob\MetadataExtractor\Metadata\Exif\ExifSubIFDDirectory;
use Gomoob\MetadataExtractor\Metadata\Tag;
use Gomoob\MetadataExtractor\Metadata\Jpeg\JpegComponent;

/**
* Reads metadata from any supported file format.
Expand Down Expand Up @@ -102,23 +103,51 @@ private static function addTagToDirectory(Directory $directory, $tagLine)
$nameAndDescription[0] = trim($nameAndDescription[0]);
$nameAndDescription[1] = trim($nameAndDescription[1]);

if ($directory instanceof JfifDirectory) {
if ($directory instanceof ExifIFD0Directory) {
var_dump($tagLine);
var_dump($nameAndDescription[0]);
var_dump($nameAndDescription[1]);

switch ($nameAndDescription[1]) {
case '':
break;
}
} elseif ($directory instanceof JfifDirectory) {
switch ($nameAndDescription[0]) {
case 'Version':
if ($nameAndDescription[1] === '1.1') {
$directory->setInt(JfifDirectory::TAG_VERSION, 0x0101);
} elseif ($nameAndDescription[1] === '1.2') {
$directory->setInt(JfifDirectory::TAG_VERSION, 0x0102);
} else {
// TODO: Version inconnue
}
break;
case 'Resolution Units':
switch ($nameAndDescription[1]) {
case 'none':
$directory->setInt(JfifDirectory::TAG_UNITS, 0);
break;
case 'inch':
$directory->setInt(JfifDirectory::TAG_UNITS, 1);
break;
case 'centimetre':
$directory->setInt(JfifDirectory::TAG_UNITS, 2);
break;
default:
$directory->setInt(JfifDirectory::TAG_UNITS, -1);
}
break;
case 'Y Resolution':
$directory->setInt(JfifDirectory::TAG_RESY, static::parseDotsString($nameAndDescription[1]));
break;
case 'X Resolution':
$directory->setInt(JfifDirectory::TAG_RESX, static::parseDotsString($nameAndDescription[1]));
break;
case 'Thumbnail Width Pixels':
$directory->setInt(JfifDirectory::TAG_THUMB_WIDTH, $nameAndDescription[1]);
break;
case 'Thumbnail Height Pixels':
$directory->setInt(JfifDirectory::TAG_THUMB_HEIGHT, $nameAndDescription[1]);
break;
default:
// TODO: Exception
Expand Down Expand Up @@ -197,6 +226,17 @@ private static function parseBitsString($bitsString)
return substr($bitsString, 0, $endPos);
}

private static function parseDotsString($dotsString)
{
$endPos = strpos($dotsString, ' dot');

if ($endPos === false) {
// TODO: Exception
}

return substr($dotsString, 0, $endPos);
}

private static function parsePixelsString($pixelsString)
{

Expand Down
4 changes: 2 additions & 2 deletions src/main/php/Gomoob/MetadataExtractor/Metadata/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ public function setInt($tagType, $value)
*/
public function setObject($tagType, $value)
{
if ($value == null) {
if ($value === null) {
throw new NullPointerException('cannot set a null object');
}

if (!array_key_exists(intval($tagType), $this->tagMap)) {
if (!array_key_exists($tagType, $this->tagMap)) {
$this->definedTagList[$tagType] = new Tag($tagType, $this);
}

Expand Down

0 comments on commit 5e5932a

Please sign in to comment.