forked from leftypol/leftypol
ImageMetadataReader: update
This commit is contained in:
parent
322543a2e0
commit
d5b4f2cd0f
3 changed files with 8 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Vichan\Service\Media;
|
namespace Vichan\Service\Media;
|
||||||
|
|
||||||
use Vichan\Data\{Exif, ImageMetadataResult};
|
use Vichan\Data\{Exif, ImageMetadata};
|
||||||
use Vichan\Functions\Mime;
|
use Vichan\Functions\Mime;
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class CmdMagickImageMetadataReader implements ImageMetadataReader {
|
||||||
$this->prefix = $prefix;
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMetadata(string $file_path): ImageMetadataResult {
|
public function getMetadata(string $file_path): ImageMetadata {
|
||||||
$arg = \escapeshellarg("$file_path[0]");
|
$arg = \escapeshellarg("$file_path[0]");
|
||||||
$ret_exec = shell_exec_error("{$this->prefix} identify -format \"%w %h %m\" $arg");
|
$ret_exec = shell_exec_error("{$this->prefix} identify -format \"%w %h %m\" $arg");
|
||||||
|
|
||||||
|
@ -65,6 +65,6 @@ class CmdMagickImageMetadataReader implements ImageMetadataReader {
|
||||||
|
|
||||||
$mime = Mime\ext_to_mime($ext) ?? 'application/octet-stream';
|
$mime = Mime\ext_to_mime($ext) ?? 'application/octet-stream';
|
||||||
$exif_orientation = self::parseOrientation($orientation_str);
|
$exif_orientation = self::parseOrientation($orientation_str);
|
||||||
return new ImageMetadataResult($width, $height, $mime, $exif_orientation);
|
return new ImageMetadata($width, $height, $mime, $exif_orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
namespace Vichan\Service\Media;
|
namespace Vichan\Service\Media;
|
||||||
|
|
||||||
use Vichan\Data\Driver\Metadata\ExifReaderFactory;
|
use Vichan\Data\Driver\Metadata\ExifReaderFactory;
|
||||||
use Vichan\Data\{Exif, ImageMetadataResult};
|
use Vichan\Data\{Exif, ImageMetadata};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@ class DefaultImageMetadataReader implements ImageMetadataReader {
|
||||||
$this->exif_reader_factory = $exif_reader_factory;
|
$this->exif_reader_factory = $exif_reader_factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMetadata(string $file_path): ImageMetadataResult {
|
public function getMetadata(string $file_path): ImageMetadata {
|
||||||
$ret = \getimagesize($file_path, $info);
|
$ret = \getimagesize($file_path, $info);
|
||||||
if ($ret === false) {
|
if ($ret === false) {
|
||||||
throw new \RuntimeException("Could not read image sizes of '$file_path'");
|
throw new \RuntimeException("Could not read image sizes of '$file_path'");
|
||||||
|
@ -45,6 +45,6 @@ class DefaultImageMetadataReader implements ImageMetadataReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ImageMetadataResult($width, $height, $mime, $orientation);
|
return new ImageMetadata($width, $height, $mime, $orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Vichan\Service\Media;
|
namespace Vichan\Service\Media;
|
||||||
|
|
||||||
use Vichan\Data\ImageMetadataResult;
|
use Vichan\Data\ImageMetadata;
|
||||||
|
|
||||||
|
|
||||||
interface ImageMetadataReader {
|
interface ImageMetadataReader {
|
||||||
/**
|
/**
|
||||||
* @param string $file_path Image file path.
|
* @param string $file_path Image file path.
|
||||||
*/
|
*/
|
||||||
public function getMetadata(string $file_path): ImageMetadataResult;
|
public function getMetadata(string $file_path): ImageMetadata;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue