Skip to content

Commit

Permalink
Composer update - php-exif 0.8 + bump to version 4.7 (#1680)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Jan 4, 2023
1 parent 2cc842f commit 60c6f34
Show file tree
Hide file tree
Showing 5 changed files with 407 additions and 355 deletions.
13 changes: 7 additions & 6 deletions app/Metadata/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Carbon\Exceptions\InvalidTimeZoneException;
use Illuminate\Support\Carbon;
use PHPExif\Adapter\NoAdapterException;
use PHPExif\Enum\ReaderType;
use PHPExif\Exif;
use PHPExif\Reader\Reader;
use Safe\Exceptions\StringsException;
Expand Down Expand Up @@ -77,10 +78,10 @@ public static function createFromFile(NativeLocalFile $file): self
// 3. Imagick (not for videos, i.e. for supported photos and accepted raw files only)
// 4. Native PHP exif reader (last resort)
$reader = match (true) {
(Configs::hasFFmpeg() && $isSupportedVideo) => Reader::factory(Reader::TYPE_FFPROBE),
Configs::hasExiftool() => Reader::factory(Reader::TYPE_EXIFTOOL),
(Configs::hasImagick() && !$isSupportedVideo) => Reader::factory(Reader::TYPE_IMAGICK),
default => Reader::factory(Reader::TYPE_NATIVE),
(Configs::hasFFmpeg() && $isSupportedVideo) => Reader::factory(ReaderType::FFPROBE),
Configs::hasExiftool() => Reader::factory(ReaderType::EXIFTOOL),
(Configs::hasImagick() && !$isSupportedVideo) => Reader::factory(ReaderType::IMAGICK),
default => Reader::factory(ReaderType::NATIVE),
};

// this can throw an exception in the case of Exiftool adapter!
Expand Down Expand Up @@ -108,7 +109,7 @@ public static function createFromFile(NativeLocalFile $file): self
try {
Logs::notice(__METHOD__, __LINE__, 'Falling back to native adapter.');
// Use Php native tools
$reader = Reader::factory(Reader::TYPE_NATIVE);
$reader = Reader::factory(ReaderType::NATIVE);
$exif = $reader->read($file->getRealPath());
} catch (\InvalidArgumentException|NoAdapterException $e) {
throw new ExternalComponentMissingException('The configured EXIF adapter is not available', $e);
Expand All @@ -132,7 +133,7 @@ public static function createFromFile(NativeLocalFile $file): self
if (Configs::hasExiftool() && $sidecarFile->exists()) {
try {
// Don't use the same reader as the file in case it's a video
$sidecarReader = Reader::factory(Reader::TYPE_EXIFTOOL);
$sidecarReader = Reader::factory(ReaderType::EXIFTOOL);
$sideCarExifData = $sidecarReader->read($sidecarFile->getRealPath());
if (!$sideCarExifData instanceof Exif) {
throw new MediaFileOperationException('Could not even extract EXIF data with the exiftool adapter');
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"laravel/framework": "^9.2",
"livewire/livewire": "^2.7",
"lychee-org/nestedset": "^6",
"lychee-org/php-exif": "^0.7.14",
"lychee-org/php-exif": "^0.8",
"maennchen/zipstream-php": "^2.1",
"php-ffmpeg/php-ffmpeg": "^1.0",
"php-http/guzzle7-adapter": "^1.0",
Expand Down
Loading

0 comments on commit 60c6f34

Please sign in to comment.