Skip to content

Commit 4d99112

Browse files
authored
Add AVIF format in Exif (#76)
1 parent 9f2d696 commit 4d99112

12 files changed

+29
-48
lines changed

tests/PHPExif/Adapter/AdapterAbstractTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function testSetOptionsCorrectlySetsProperties()
3939

4040
foreach ($expected as $key => $value) {
4141
$reflProp = new \ReflectionProperty(Native::class, $key);
42-
$reflProp->setAccessible(true);
4342
$this->assertEquals($value, $reflProp->getValue($this->adapter));
4443
}
4544
}
@@ -56,7 +55,6 @@ public function testSetOptionsIgnoresPropertiesWithoutSetters()
5655

5756
foreach ($expected as $key => $value) {
5857
$reflProp = new \ReflectionProperty(Native::class, $key);
59-
$reflProp->setAccessible(true);
6058
$this->assertNotEquals($value, $reflProp->getValue($this->adapter));
6159
}
6260
}
@@ -76,7 +74,6 @@ public function testConstructorSetsOptions()
7674

7775
foreach ($expected as $key => $value) {
7876
$reflProp = new \ReflectionProperty(Native::class, $key);
79-
$reflProp->setAccessible(true);
8077
$this->assertEquals($value, $reflProp->getValue($adapter));
8178
}
8279
}
@@ -100,7 +97,6 @@ public function testSetMapperCorrectlySetsInProperty()
10097
$this->adapter->setMapper($mapper);
10198

10299
$reflProp = new \ReflectionProperty(AbstractAdapter::class, 'mapper');
103-
$reflProp->setAccessible(true);
104100
$this->assertSame($mapper, $reflProp->getValue($this->adapter));
105101
}
106102

@@ -111,7 +107,6 @@ public function testGetMapperCorrectlyReturnsFromProperty()
111107
{
112108
$mapper = new \PHPExif\Mapper\Native();
113109
$reflProp = new \ReflectionProperty(AbstractAdapter::class, 'mapper');
114-
$reflProp->setAccessible(true);
115110
$reflProp->setValue($this->adapter, $mapper);
116111
$this->assertSame($mapper, $this->adapter->getMapper());
117112
}
@@ -127,7 +122,6 @@ public function testGetMapperLazyLoadsMapperWhenNotPresent()
127122
);
128123

129124
$mapperClass = '\\PHPExif\\Mapper\\Native';
130-
$reflProp->setAccessible(true);
131125
$reflProp->setValue($this->adapter, $mapperClass);
132126

133127
$this->assertInstanceOf($mapperClass, $this->adapter->getMapper());
@@ -144,14 +138,12 @@ public function testGetMapperLazyLoadingSetsInProperty()
144138
);
145139

146140
$mapperClass = '\\PHPExif\\Mapper\\Native';
147-
$reflProp->setAccessible(true);
148141
$reflProp->setValue($this->adapter, $mapperClass);
149142

150143
$reflProp2 = new \ReflectionProperty(
151144
get_class($this->adapter),
152145
'mapper'
153146
);
154-
$reflProp2->setAccessible(true);
155147
$this->adapter->getMapper();
156148
$this->assertInstanceOf($mapperClass, $reflProp2->getValue($this->adapter));
157149
}
@@ -175,7 +167,6 @@ public function testSetHydratorCorrectlySetsInProperty()
175167
$this->adapter->setHydrator($hydrator);
176168

177169
$reflProp = new \ReflectionProperty(AbstractAdapter::class, 'hydrator');
178-
$reflProp->setAccessible(true);
179170
$this->assertSame($hydrator, $reflProp->getValue($this->adapter));
180171
}
181172

@@ -186,7 +177,6 @@ public function testGetHydratorCorrectlyReturnsFromProperty()
186177
{
187178
$hydrator = new \PHPExif\Hydrator\Mutator();
188179
$reflProp = new \ReflectionProperty(AbstractAdapter::class, 'hydrator');
189-
$reflProp->setAccessible(true);
190180
$reflProp->setValue($this->adapter, $hydrator);
191181
$this->assertSame($hydrator, $this->adapter->getHydrator());
192182
}
@@ -211,7 +201,6 @@ public function testGetHydratorLazyLoadingSetsInProperty()
211201
get_class($this->adapter),
212202
'hydrator'
213203
);
214-
$reflProp->setAccessible(true);
215204
$this->adapter->getHydrator();
216205
$this->assertInstanceOf($hydratorClass, $reflProp->getValue($this->adapter));
217206
}

tests/PHPExif/Adapter/ExiftoolProcOpenTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public function testGetCliOutput()
5555
{
5656
$this->expectException(PhpExifReaderException::class);
5757
$reflMethod = new \ReflectionMethod(Exiftool::class, 'getCliOutput');
58-
$reflMethod->setAccessible(true);
5958

6059
$result = $reflMethod->invoke(
6160
$this->adapter,

tests/PHPExif/Adapter/ExiftoolTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public function setUp(): void
1717
public function testGetToolPathFromProperty()
1818
{
1919
$reflProperty = new \ReflectionProperty(Exiftool::class, 'toolPath');
20-
$reflProperty->setAccessible(true);
2120
$expected = '/foo/bar/baz';
2221
$reflProperty->setValue($this->adapter, $expected);
2322

@@ -30,7 +29,6 @@ public function testGetToolPathFromProperty()
3029
public function testSetToolPathInProperty()
3130
{
3231
$reflProperty = new \ReflectionProperty(Exiftool::class, 'toolPath');
33-
$reflProperty->setAccessible(true);
3432

3533
$expected = '/tmp';
3634
$this->adapter->setToolPath($expected);
@@ -62,7 +60,6 @@ public function testGetToolPathLazyLoadsPath()
6260
public function testSetNumericInProperty()
6361
{
6462
$reflProperty = new \ReflectionProperty(Exiftool::class, 'numeric');
65-
$reflProperty->setAccessible(true);
6663

6764
$expected = true;
6865
$this->adapter->setNumeric($expected);
@@ -77,7 +74,6 @@ public function testSetNumericInProperty()
7774
public function testSetEncodingInProperty()
7875
{
7976
$reflProperty = new \ReflectionProperty(Exiftool::class, 'encoding');
80-
$reflProperty->setAccessible(true);
8177

8278
$expected = array('iptc' => 'cp1250');
8379
$input = array('iptc' => 'cp1250', 'exif' => 'utf8', 'foo' => 'bar');
@@ -112,13 +108,25 @@ public function testGetExifFromFileWithUtf8()
112108
$this->assertNotEmpty($result->getRawData());
113109
}
114110

111+
/**
112+
* @group exiftool
113+
*/
114+
public function testGetExifFromFileWithAvif()
115+
{
116+
$file = PHPEXIF_TEST_ROOT . '/files/fox.profile0.10bpc.yuv420.avif';
117+
$this->adapter->setOptions(array('encoding' => array('utf8')));
118+
$result = $this->adapter->getExifFromFile($file);
119+
$this->assertInstanceOf('\PHPExif\Exif', $result);
120+
$this->assertIsArray($result->getRawData());
121+
$this->assertNotEmpty($result->getRawData());
122+
}
123+
115124
/**
116125
* @group exiftool
117126
*/
118127
public function testGetCliOutput()
119128
{
120129
$reflMethod = new \ReflectionMethod(Exiftool::class, 'getCliOutput');
121-
$reflMethod->setAccessible(true);
122130

123131
$result = $reflMethod->invoke(
124132
$this->adapter,

tests/PHPExif/Adapter/FFprobeTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function setUp(): void
2323
public function testGetToolPathFromProperty()
2424
{
2525
$reflProperty = new \ReflectionProperty(FFprobe::class, 'toolPath');
26-
$reflProperty->setAccessible(true);
2726
$expected = '/foo/bar/baz';
2827
$reflProperty->setValue($this->adapter, $expected);
2928

@@ -36,7 +35,6 @@ public function testGetToolPathFromProperty()
3635
public function testSetToolPathInProperty()
3736
{
3837
$reflProperty = new \ReflectionProperty(FFprobe::class, 'toolPath');
39-
$reflProperty->setAccessible(true);
4038

4139
$expected = '/tmp';
4240
$this->adapter->setToolPath($expected);

tests/PHPExif/Adapter/NativeTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public function setUp(): void
2020
public function testSetIncludeThumbnailInProperty()
2121
{
2222
$reflProperty = new \ReflectionProperty(Native::class, 'includeThumbnail');
23-
$reflProperty->setAccessible(true);
2423

2524
$this->assertEquals(Native::NO_THUMBNAIL, $reflProperty->getValue($this->adapter));
2625

@@ -35,7 +34,6 @@ public function testSetIncludeThumbnailInProperty()
3534
public function testGetIncludeThumbnailFromProperty()
3635
{
3736
$reflProperty = new \ReflectionProperty(Native::class, 'includeThumbnail');
38-
$reflProperty->setAccessible(true);
3937
$reflProperty->setValue($this->adapter, Native::INCLUDE_THUMBNAIL);
4038

4139
$this->assertEquals(Native::INCLUDE_THUMBNAIL, $this->adapter->getIncludeThumbnail());
@@ -55,7 +53,6 @@ public function testGetIncludeThumbnailHasDefaultValue()
5553
public function testGetRequiredSections()
5654
{
5755
$reflProperty = new \ReflectionProperty(Native::class, 'requiredSections');
58-
$reflProperty->setAccessible(true);
5956

6057
$this->assertEquals($reflProperty->getValue($this->adapter), $this->adapter->getRequiredSections());
6158
}
@@ -66,7 +63,6 @@ public function testGetRequiredSections()
6663
public function testSetRequiredSections()
6764
{
6865
$reflProperty = new \ReflectionProperty(Native::class, 'requiredSections');
69-
$reflProperty->setAccessible(true);
7066

7167
$testData = array('foo', 'bar', 'baz');
7268

@@ -82,7 +78,6 @@ public function testSetRequiredSections()
8278
public function testAddRequiredSection()
8379
{
8480
$reflProperty = new \ReflectionProperty(Native::class, 'requiredSections');
85-
$reflProperty->setAccessible(true);
8681

8782
$testData = array('foo', 'bar', 'baz');
8883
$this->adapter->setRequiredSections($testData);
@@ -153,7 +148,6 @@ public function testGetEmptyIptcData()
153148
public function testSetSectionsAsArrayInProperty()
154149
{
155150
$reflProperty = new \ReflectionProperty(Native::class, 'sectionsAsArrays');
156-
$reflProperty->setAccessible(true);
157151
$expected = Native::SECTIONS_AS_ARRAYS;
158152
$this->adapter->setSectionsAsArrays($expected);
159153
$actual = $reflProperty->getValue($this->adapter);
@@ -166,7 +160,6 @@ public function testSetSectionsAsArrayInProperty()
166160
public function testSetSectionsAsArrayConvertsToBoolean()
167161
{
168162
$reflProperty = new \ReflectionProperty(Native::class, 'sectionsAsArrays');
169-
$reflProperty->setAccessible(true);
170163
$expected = Native::SECTIONS_AS_ARRAYS;
171164
$this->adapter->setSectionsAsArrays('Foo');
172165
$actual = $reflProperty->getValue($this->adapter);
@@ -179,7 +172,6 @@ public function testSetSectionsAsArrayConvertsToBoolean()
179172
public function testGetSectionsAsArrayFromProperty()
180173
{
181174
$reflProperty = new \ReflectionProperty(Native::class, 'sectionsAsArrays');
182-
$reflProperty->setAccessible(true);
183175
$reflProperty->setValue($this->adapter, Native::SECTIONS_AS_ARRAYS);
184176

185177
$this->assertEquals(Native::SECTIONS_AS_ARRAYS, $this->adapter->getSectionsAsArrays());

tests/PHPExif/ExifTest.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function testConstructorCallsSetData()
4848
public function testGetRawData()
4949
{
5050
$reflProperty = new \ReflectionProperty(Exif::class, 'rawData');
51-
$reflProperty->setAccessible(true);
5251

5352
$this->assertEquals($reflProperty->getValue($this->exif), $this->exif->getRawData());
5453
}
@@ -60,7 +59,6 @@ public function testSetRawData()
6059
{
6160
$testData = array('foo', 'bar', 'baz');
6261
$reflProperty = new \ReflectionProperty(Exif::class, 'rawData');
63-
$reflProperty->setAccessible(true);
6462

6563
$result = $this->exif->setRawData($testData);
6664

@@ -74,7 +72,6 @@ public function testSetRawData()
7472
public function testGetData()
7573
{
7674
$reflProperty = new \ReflectionProperty(Exif::class, 'data');
77-
$reflProperty->setAccessible(true);
7875

7976
$this->assertEquals($reflProperty->getValue($this->exif), $this->exif->getData());
8077
}
@@ -86,7 +83,6 @@ public function testSetData()
8683
{
8784
$testData = array('foo', 'bar', 'baz');
8885
$reflProperty = new \ReflectionProperty(Exif::class, 'data');
89-
$reflProperty->setAccessible(true);
9086

9187
$result = $this->exif->setData($testData);
9288

@@ -653,7 +649,6 @@ public function testMutatorMethodsSetInProperty()
653649
$constants = $reflClass->getConstants();
654650

655651
$reflProp = new \ReflectionProperty(get_class($this->exif), 'data');
656-
$reflProp->setAccessible(true);
657652

658653
$expected = 'foo';
659654
foreach ($constants as $name => $value) {
@@ -788,5 +783,20 @@ public function testAdapterConsistency()
788783
);
789784
}
790785
}
786+
787+
// Test for .avif type image for Native adapter
788+
$testfiles = array(
789+
PHPEXIF_TEST_ROOT . '/files/fox.profile0.10bpc.yuv420.avif',
790+
);
791+
792+
foreach ($testfiles as $file) {
793+
$file_name = basename($file);
794+
$adapter_native = new \PHPExif\Adapter\Native();
795+
$result_exif_native = $adapter_native->getExifFromFile($file);
796+
797+
$this->assertEquals($file_name, $result_exif_native->getFileName());
798+
$this->assertEquals('image/avif', $result_exif_native->getMimeType());
799+
$this->assertIsNumeric($result_exif_native->getWidth());
800+
}
791801
}
792802
}

tests/PHPExif/Mapper/ExiftoolMapperTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public function testMapRawDataIgnoresFieldIfItDoesntExist()
3737
public function testMapRawDataMapsFieldsCorrectly()
3838
{
3939
$reflProp = new \ReflectionProperty(get_class($this->mapper), 'map');
40-
$reflProp->setAccessible(true);
4140
$map = $reflProp->getValue($this->mapper);
4241

4342
// ignore custom formatted data stuff:
@@ -441,7 +440,6 @@ public function testMapRawDataCorrectImageDirection()
441440
public function testSetNumericInProperty()
442441
{
443442
$reflProperty = new \ReflectionProperty(get_class($this->mapper), 'numeric');
444-
$reflProperty->setAccessible(true);
445443

446444
$expected = true;
447445
$this->mapper->setNumeric($expected);

tests/PHPExif/Mapper/FFprobeMapperTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public function testMapRawDataIgnoresFieldIfItDoesntExist()
3838
public function testMapRawDataMapsFieldsCorrectly()
3939
{
4040
$reflProp = new \ReflectionProperty(get_class($this->mapper), 'map');
41-
$reflProp->setAccessible(true);
4241
$map = $reflProp->getValue($this->mapper);
4342

4443
// ignore custom formatted data stuff:
@@ -307,7 +306,6 @@ public function testMapRawDataCorrectlyIgnoresInvalidCreateDate()
307306
public function testNormalizeComponentCorrectly()
308307
{
309308
$reflMethod = new \ReflectionMethod(FFprobe::class, 'normalizeComponent');
310-
$reflMethod->setAccessible(true);
311309

312310
$rawData = array(
313311
'2/800' => 0.0025,
@@ -354,7 +352,6 @@ public function testMapRawDataMatchesFieldsWithoutCaseSensibilityOnFirstLetter()
354352
public function testreadISO6709()
355353
{
356354
$reflMethod = new \ReflectionMethod(FFprobe::class, 'readISO6709');
357-
$reflMethod->setAccessible(true);
358355

359356
$testcase = array(
360357
'+27.5916+086.5640+8850/' => array(
@@ -417,7 +414,6 @@ public function testconvertDMStoDecimal()
417414
{
418415

419416
$reflMethod = new \ReflectionMethod(FFprobe::class, 'convertDMStoDecimal');
420-
$reflMethod->setAccessible(true);
421417

422418
$testcase = array(
423419
'+27.5916' => array(

tests/PHPExif/Mapper/ImageMagickMapperTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public function testMapRawDataIgnoresFieldIfItDoesntExist()
3737
public function testMapRawDataMapsFieldsCorrectly()
3838
{
3939
$reflProp = new \ReflectionProperty(get_class($this->mapper), 'map');
40-
$reflProp->setAccessible(true);
4140
$map = $reflProp->getValue($this->mapper);
4241

4342
// ignore custom formatted data stuff:
@@ -487,7 +486,6 @@ public function testMapRawDataCorrectlyWidthPNG()
487486
public function testNormalizeComponentCorrectly()
488487
{
489488
$reflMethod = new \ReflectionMethod(ImageMagick::class, 'normalizeComponent');
490-
$reflMethod->setAccessible(true);
491489

492490
$rawData = array(
493491
'2/800' => 0.0025,

tests/PHPExif/Mapper/NativeMapperTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public function testMapRawDataIgnoresFieldIfItDoesntExist()
3737
public function testMapRawDataMapsFieldsCorrectly()
3838
{
3939
$reflProp = new \ReflectionProperty(get_class($this->mapper), 'map');
40-
$reflProp->setAccessible(true);
4140
$map = $reflProp->getValue($this->mapper);
4241

4342
// ignore custom formatted data stuff:
@@ -175,7 +174,7 @@ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone3()
175174
$result->getTimezone()->getName()
176175
);
177176
}
178-
177+
179178
/**
180179
* @group mapper
181180
*/
@@ -455,7 +454,6 @@ public function testMapRawDataCorrectlyIgnoresInvalidCreateDate()
455454
public function testNormalizeComponentCorrectly()
456455
{
457456
$reflMethod = new \ReflectionMethod(Native::class, 'normalizeComponent');
458-
$reflMethod->setAccessible(true);
459457

460458
$rawData = array(
461459
'2/800' => 0.0025,

0 commit comments

Comments
 (0)