forked from PHPExif/php-exif
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New MapperAbstract class with a recursive trim * Support IPTC:CopyrightNotice * Support more EXIF tags * Support EXIF ImageDescription * Add more test images * Fix the GPS rounding code * fix Copyrights Co-authored-by: ildyria <[email protected]>
- Loading branch information
Showing
26 changed files
with
109 additions
and
189 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
<?php | ||
/** | ||
* PHP Exif Reader Adapter Abstract: Common functionality for adapters | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2013 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Reader | ||
*/ | ||
|
||
namespace PHPExif\Adapter; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
<?php | ||
/** | ||
* PHP Exif Reader Adapter Interface: Defines the interface for reader adapters | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2013 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Reader | ||
* @codeCoverageIgnore | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
<?php | ||
/** | ||
* PHP Exif Exiftool Reader Adapter | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2013 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Reader | ||
*/ | ||
|
||
namespace PHPExif\Adapter; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
<?php | ||
/** | ||
* PHP Exif Imagick Reader Adapter | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2013 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Reader | ||
*/ | ||
|
||
namespace PHPExif\Adapter; | ||
|
||
|
@@ -83,6 +74,8 @@ public function getExifFromFile(string $file) : Exif | |
} | ||
|
||
$data = array_merge($data_exif, $data_iptc, $additional_data); | ||
// Force UTF8 encoding | ||
$data = $this->convertToUTF8($data); | ||
|
||
// map the data: | ||
$mapper = $this->getMapper(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,9 @@ | ||
<?php | ||
/** | ||
* PHP Exif Native Reader Adapter | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2013 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Reader | ||
*/ | ||
|
||
namespace PHPExif\Adapter; | ||
|
||
use PHPExif\Exif; | ||
use Safe\Exceptions\ImageException; | ||
use Throwable; | ||
|
||
use function Safe\mime_content_type; | ||
use function Safe\filesize; | ||
|
@@ -229,7 +219,7 @@ public function getExifFromFile(string $file) : Exif | |
// Fail silently | ||
} | ||
} | ||
|
||
// Force UTF8 encoding | ||
$data = $this->convertToUTF8($data); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
<?php | ||
/** | ||
* PHP Exif Reader Adapter Interface: Defines the interface for reader adapters | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2013 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Reader | ||
* @codeCoverageIgnore | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
<?php | ||
/** | ||
* PHP Exif Reader: Reads EXIF metadata from a file, without having to install additional PHP modules | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2013 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Exif | ||
*/ | ||
|
||
namespace PHPExif; | ||
|
||
|
@@ -20,7 +11,6 @@ | |
* | ||
* @category PHPExif | ||
* @package Exif | ||
* @ | ||
*/ | ||
class Exif | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
<?php | ||
/** | ||
* PHP Exif Hydrator Interface: Defines the interface for a hydrator | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2015 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Hydrator | ||
* @codeCoverageIgnore | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
<?php | ||
/** | ||
* PHP Exif Mutator Hydrator: Hydrate an object | ||
* by manipulating the object with its mutator methods | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2015 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Hydrator | ||
*/ | ||
|
||
namespace PHPExif\Hydrator; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
<?php | ||
/** | ||
* PHP Exif Native Mapper | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2015 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Mapper | ||
*/ | ||
|
||
namespace PHPExif\Mapper; | ||
|
||
|
@@ -24,7 +15,7 @@ | |
* @category PHPExif | ||
* @package Mapper | ||
*/ | ||
class FFprobe implements MapperInterface | ||
class FFprobe extends MapperAbstract | ||
{ | ||
const HEIGHT = 'height'; | ||
const WIDTH = 'width'; | ||
|
@@ -114,6 +105,7 @@ public function mapRawData(array $data) : array | |
} | ||
|
||
$key = $this->map[$field]; | ||
$value = $this->trim($value); | ||
|
||
// manipulate the value if necessary | ||
switch ($field) { | ||
|
@@ -286,7 +278,7 @@ public function convertDMStoDecimal( | |
if ($sign === '-') { | ||
$decimal = -1.0 * $decimal; | ||
} | ||
return $decimal; | ||
return round($decimal, self::ROUNDING_PRECISION); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
<?php | ||
/** | ||
* PHP Imagick Exiftool Mapper | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2015 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Mapper | ||
*/ | ||
|
||
namespace PHPExif\Mapper; | ||
|
||
|
@@ -26,13 +17,15 @@ | |
* @category PHPExif | ||
* @package Mapper | ||
*/ | ||
class ImageMagick implements MapperInterface | ||
class ImageMagick extends MapperAbstract | ||
{ | ||
const APERTURE = 'exif:FNumber'; | ||
const ARTIST = 'exif:Artist'; | ||
const COLORSPACE = 'exif:ColorSpace'; | ||
const COPYRIGHT = 'exif:Copyright'; | ||
const CREATION_DATE = 'date:create'; | ||
const DATETIMEORIGINAL = 'exif:DateTimeOriginal'; | ||
const DESCRIPTION = 'exif:ImageDescription '; | ||
const DESCRIPTION = 'exif:ImageDescription'; | ||
const EXPOSURETIME = 'exif:ExposureTime'; | ||
const FILESIZE = 'filesize'; | ||
const FILENAME = 'filename'; | ||
|
@@ -58,7 +51,7 @@ class ImageMagick implements MapperInterface | |
const YRESOLUTION = 'exif:YResolution'; | ||
const TITLE = 'iptc:title'; | ||
const KEYWORDS = 'iptc:keywords'; | ||
const COPYRIGHT = 'iptc:copyright'; | ||
const COPYRIGHT_IPTC = 'iptc:copyright'; | ||
const CAPTION = 'iptc:caption'; | ||
const HEADLINE = 'iptc:headline'; | ||
const CREDIT = 'iptc:credit'; | ||
|
@@ -78,7 +71,9 @@ class ImageMagick implements MapperInterface | |
*/ | ||
protected array $map = array( | ||
self::APERTURE => Exif::APERTURE, | ||
self::ARTIST => Exif::AUTHOR, | ||
self::COLORSPACE => Exif::COLORSPACE, | ||
self::COPYRIGHT => Exif::COPYRIGHT, | ||
self::CREATION_DATE => Exif::CREATION_DATE, | ||
self::DATETIMEORIGINAL => Exif::CREATION_DATE, | ||
self::DESCRIPTION => Exif::DESCRIPTION, | ||
|
@@ -107,7 +102,7 @@ class ImageMagick implements MapperInterface | |
self::YRESOLUTION => Exif::VERTICAL_RESOLUTION, | ||
self::TITLE => Exif::TITLE, | ||
self::KEYWORDS => Exif::KEYWORDS, | ||
self::COPYRIGHT => Exif::COPYRIGHT, | ||
self::COPYRIGHT_IPTC => Exif::COPYRIGHT, | ||
self::CAPTION => Exif::CAPTION, | ||
self::HEADLINE => Exif::HEADLINE, | ||
self::CREDIT => Exif::CREDIT, | ||
|
@@ -139,6 +134,7 @@ public function mapRawData(array $data) : array | |
} | ||
|
||
$key = $this->map[$field]; | ||
$value = $this->trim($value); | ||
|
||
// manipulate the value if necessary | ||
switch ($field) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace PHPExif\Mapper; | ||
|
||
/** | ||
* PHP Exif Mapper Abstract | ||
* | ||
* Implements common functionality for data mappers | ||
* | ||
* @category PHPExif | ||
* @package Mapper | ||
*/ | ||
abstract class MapperAbstract implements MapperInterface | ||
{ | ||
/** | ||
* Trim whitespaces recursively | ||
* | ||
* @param mixed $data | ||
* @return mixed | ||
*/ | ||
public function trim(mixed $data) : mixed | ||
{ | ||
if (is_array($data)) { | ||
/** @var mixed $v */ | ||
foreach ($data as $k => $v) { | ||
$data[$k] = $this->trim($v); | ||
} | ||
} elseif (is_string($data)) { | ||
$data = trim($data); | ||
} | ||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
<?php | ||
/** | ||
* PHP Exif Mapper Interface: Defines the interface for data mappers | ||
* | ||
* @link http://github.com/miljar/PHPExif for the canonical source repository | ||
* @copyright Copyright (c) 2015 Tom Van Herreweghe <[email protected]> | ||
* @license http://github.com/miljar/PHPExif/blob/master/LICENSE MIT License | ||
* @category PHPExif | ||
* @package Mapper | ||
* @codeCoverageIgnore | ||
*/ | ||
|
||
|
Oops, something went wrong.