Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/PHPExif/Adapter/Exiftool.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function getExifFromFile($file)
{
$result = $this->getCliOutput(
sprintf(
'%1$s%3$s -j -a -G0 -c %4$s %2$s',
'%1$s%3$s -j -a -G1 -c %4$s %2$s',
$this->getToolPath(),
escapeshellarg($file),
$this->numeric ? ' -n' : '',
Expand Down
42 changes: 21 additions & 21 deletions lib/PHPExif/Mapper/Exiftool.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,33 @@
class Exiftool implements MapperInterface
{
const APERTURE = 'Composite:Aperture';
const APPROXIMATEFOCUSDISTANCE = 'XMP:ApproximateFocusDistance';
const ARTIST = 'EXIF:Artist';
const CAPTION = 'XMP:Caption';
const APPROXIMATEFOCUSDISTANCE = 'XMP-aux:ApproximateFocusDistance';
const ARTIST = 'IFD0:Artist';
const CAPTION = 'XMP-acdsee';
const CAPTIONABSTRACT = 'IPTC:Caption-Abstract';
const COLORSPACE = 'EXIF:ColorSpace';
const COPYRIGHT = 'EXIF:Copyright';
const CREATEDATE = 'EXIF:CreateDate';
const COLORSPACE = 'ExifIFD:ColorSpace';
const COPYRIGHT = 'IFD0:Copyright';
const DATETIMEORIGINAL = 'ExifIFD:DateTimeOriginal';
const CREDIT = 'IPTC:Credit';
const EXPOSURETIME = 'EXIF:ExposureTime';
const FILESIZE = 'File:FileSize';
const FOCALLENGTH = 'EXIF:FocalLength';
const EXPOSURETIME = 'ExifIFD:ExposureTime';
const FILESIZE = 'System:FileSize';
const FOCALLENGTH = 'ExifIFD:FocalLength';
const HEADLINE = 'IPTC:Headline';
const IMAGEHEIGHT = 'File:ImageHeight';
const IMAGEWIDTH = 'File:ImageWidth';
const ISO = 'EXIF:ISO';
const ISO = 'ExifIFD:ISO';
const JOBTITLE = 'IPTC:By-lineTitle';
const KEYWORDS = 'IPTC:Keywords';
const MIMETYPE = 'File:MIMEType';
const MODEL = 'EXIF:Model';
const ORIENTATION = 'EXIF:Orientation';
const SOFTWARE = 'EXIF:Software';
const MODEL = 'IFD0:Model';
const ORIENTATION = 'IFD0:Orientation';
const SOFTWARE = 'IFD0:Software';
const SOURCE = 'IPTC:Source';
const TITLE = 'IPTC:ObjectName';
const XRESOLUTION = 'EXIF:XResolution';
const YRESOLUTION = 'EXIF:YResolution';
const GPSLATITUDE = 'EXIF:GPSLatitude';
const GPSLONGITUDE = 'EXIF:GPSLongitude';
const XRESOLUTION = 'IFD0:XResolution';
const YRESOLUTION = 'IFD0:YResolution';
const GPSLATITUDE = 'GPS:GPSLatitude';
const GPSLONGITUDE = 'GPS:GPSLongitude';

/**
* Maps the ExifTool fields to the fields of
Expand All @@ -66,7 +66,7 @@ class Exiftool implements MapperInterface
self::CAPTION => Exif::CAPTION,
self::COLORSPACE => Exif::COLORSPACE,
self::COPYRIGHT => Exif::COPYRIGHT,
self::CREATEDATE => Exif::CREATION_DATE,
self::DATETIMEORIGINAL => Exif::CREATION_DATE,
self::CREDIT => Exif::CREDIT,
self::EXPOSURETIME => Exif::EXPOSURE,
self::FILESIZE => Exif::FILESIZE,
Expand Down Expand Up @@ -135,7 +135,7 @@ public function mapRawData(array $data)
case self::APPROXIMATEFOCUSDISTANCE:
$value = sprintf('%1$sm', $value);
break;
case self::CREATEDATE:
case self::DATETIMEORIGINAL:
try {
$value = new DateTime($value);
} catch (\Exception $exception) {
Expand Down Expand Up @@ -172,8 +172,8 @@ public function mapRawData(array $data)

// add GPS coordinates, if available
if (count($gpsData) === 2 && $gpsData['lat'] !== false && $gpsData['lon'] !== false) {
$latitudeRef = empty($data['EXIF:GPSLatitudeRef'][0]) ? 'N' : $data['EXIF:GPSLatitudeRef'][0];
$longitudeRef = empty($data['EXIF:GPSLongitudeRef'][0]) ? 'E' : $data['EXIF:GPSLongitudeRef'][0];
$latitudeRef = empty($data['GPS:GPSLatitudeRef'][0]) ? 'N' : $data['GPS:GPSLatitudeRef'][0];
$longitudeRef = empty($data['GPS:GPSLongitudeRef'][0]) ? 'E' : $data['GPS:GPSLongitudeRef'][0];

$gpsLocation = sprintf(
'%s,%s',
Expand Down
38 changes: 19 additions & 19 deletions tests/PHPExif/Mapper/ExiftoolMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testMapRawDataMapsFieldsCorrectly()
// ignore custom formatted data stuff:
unset($map[\PHPExif\Mapper\Exiftool::APERTURE]);
unset($map[\PHPExif\Mapper\Exiftool::APPROXIMATEFOCUSDISTANCE]);
unset($map[\PHPExif\Mapper\Exiftool::CREATEDATE]);
unset($map[\PHPExif\Mapper\Exiftool::DATETIMEORIGINAL]);
unset($map[\PHPExif\Mapper\Exiftool::EXPOSURETIME]);
unset($map[\PHPExif\Mapper\Exiftool::FOCALLENGTH]);
unset($map[\PHPExif\Mapper\Exiftool::GPSLATITUDE]);
Expand Down Expand Up @@ -103,7 +103,7 @@ public function testMapRawDataCorrectlyFormatsFocusDistance()
public function testMapRawDataCorrectlyFormatsCreationDate()
{
$rawData = array(
\PHPExif\Mapper\Exiftool::CREATEDATE => '2015:04:01 12:11:09',
\PHPExif\Mapper\Exiftool::DATETIMEORIGINAL => '2015:04:01 12:11:09',
);

$mapped = $this->mapper->mapRawData($rawData);
Expand All @@ -123,7 +123,7 @@ public function testMapRawDataCorrectlyFormatsCreationDate()
public function testMapRawDataCorrectlyIgnoresIncorrectCreationDate()
{
$rawData = array(
\PHPExif\Mapper\Exiftool::CREATEDATE => '2015:04:01',
\PHPExif\Mapper\Exiftool::DATETIMEORIGINAL => '2015:04:01',
);

$mapped = $this->mapper->mapRawData($rawData);
Expand Down Expand Up @@ -177,10 +177,10 @@ public function testMapRawDataCorrectlyFormatsGPSData()
$this->mapper->setNumeric(false);
$result = $this->mapper->mapRawData(
array(
'EXIF:GPSLatitude' => '40 deg 20\' 0.42857" N',
'EXIF:GPSLatitudeRef' => 'North',
'EXIF:GPSLongitude' => '20 deg 10\' 2.33333" W',
'EXIF:GPSLongitudeRef' => 'West',
\PHPExif\Mapper\Exiftool::GPSLATITUDE => '40 deg 20\' 0.42857" N',
'GPS:GPSLatitudeRef' => 'North',
\PHPExif\Mapper\Exiftool::GPSLONGITUDE => '20 deg 10\' 2.33333" W',
'GPS:GPSLongitudeRef' => 'West',
)
);

Expand All @@ -197,10 +197,10 @@ public function testMapRawDataCorrectlyFormatsNumericGPSData()
{
$result = $this->mapper->mapRawData(
array(
'EXIF:GPSLatitude' => '40.333452381',
'EXIF:GPSLatitudeRef' => 'North',
'EXIF:GPSLongitude' => '20.167314814',
'EXIF:GPSLongitudeRef' => 'West',
\PHPExif\Mapper\Exiftool::GPSLATITUDE => '40.333452381',
'GPS:GPSLatitudeRef' => 'North',
\PHPExif\Mapper\Exiftool::GPSLONGITUDE => '20.167314814',
'GPS:GPSLongitudeRef' => 'West',
)
);

Expand All @@ -218,10 +218,10 @@ public function testMapRawDataCorrectlyIgnoresIncorrectGPSData()
$this->mapper->setNumeric(false);
$result = $this->mapper->mapRawData(
array(
'EXIF:GPSLatitude' => '40.333452381',
'EXIF:GPSLatitudeRef' => 'North',
'EXIF:GPSLongitude' => '20.167314814',
'EXIF:GPSLongitudeRef' => 'West',
\PHPExif\Mapper\Exiftool::GPSLATITUDE => '40.333452381',
'GPS:GPSLatitudeRef' => 'North',
\PHPExif\Mapper\Exiftool::GPSLONGITUDE => '20.167314814',
'GPS:GPSLongitudeRef' => 'West',
)
);

Expand All @@ -236,8 +236,8 @@ public function testMapRawDataCorrectlyIgnoresIncompleteGPSData()
{
$result = $this->mapper->mapRawData(
array(
'EXIF:GPSLatitude' => '40.333452381',
'EXIF:GPSLatitudeRef' => 'North',
\PHPExif\Mapper\Exiftool::GPSLATITUDE => '40.333452381',
'GPS:GPSLatitudeRef' => 'North',
)
);

Expand All @@ -262,7 +262,7 @@ public function testSetNumericInProperty()
public function testMapRawDataCorrectlyFormatsDifferentDateTimeString()
{
$rawData = array(
\PHPExif\Mapper\Exiftool::CREATEDATE => '2014-12-15 00:12:00'
\PHPExif\Mapper\Exiftool::DATETIMEORIGINAL => '2014-12-15 00:12:00'
);

$mapped = $this->mapper->mapRawData(
Expand All @@ -280,7 +280,7 @@ public function testMapRawDataCorrectlyFormatsDifferentDateTimeString()
public function testMapRawDataCorrectlyIgnoresInvalidCreateDate()
{
$rawData = array(
\PHPExif\Mapper\Exiftool::CREATEDATE => 'Invalid Date String'
\PHPExif\Mapper\Exiftool::DATETIMEORIGINAL => 'Invalid Date String'
);

$result = $this->mapper->mapRawData(
Expand Down