mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 22:17:03 +03:00
Added: Incorrect image orientation
This commit is contained in:
parent
217207883f
commit
e3b62d24d8
87 changed files with 10461 additions and 21 deletions
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imagine package.
|
||||
*
|
||||
* (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Imagine\Image;
|
||||
|
||||
use Imagine\Image\Metadata\DefaultMetadataReader;
|
||||
use Imagine\Image\Metadata\ExifMetadataReader;
|
||||
use Imagine\Image\Metadata\MetadataReaderInterface;
|
||||
use Imagine\Exception\InvalidArgumentException;
|
||||
|
||||
abstract class AbstractImagine implements ImagineInterface
|
||||
{
|
||||
/** @var MetadataReaderInterface */
|
||||
private $metadataReader;
|
||||
|
||||
/**
|
||||
* @param MetadataReaderInterface $metadataReader
|
||||
*
|
||||
* @return ImagineInterface
|
||||
*/
|
||||
public function setMetadataReader(MetadataReaderInterface $metadataReader)
|
||||
{
|
||||
$this->metadataReader = $metadataReader;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MetadataReaderInterface
|
||||
*/
|
||||
public function getMetadataReader()
|
||||
{
|
||||
if (null === $this->metadataReader) {
|
||||
if (ExifMetadataReader::isSupported()) {
|
||||
$this->metadataReader = new ExifMetadataReader();
|
||||
} else {
|
||||
$this->metadataReader = new DefaultMetadataReader();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->metadataReader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a path that could be used with ImagineInterface::open and returns
|
||||
* a proper string.
|
||||
*
|
||||
* @param string|object $path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws InvalidArgumentException In case the given path is invalid.
|
||||
*/
|
||||
protected function checkPath($path)
|
||||
{
|
||||
// provide compatibility with objects such as \SplFileInfo
|
||||
if (is_object($path) && method_exists($path, '__toString')) {
|
||||
$path = (string) $path;
|
||||
}
|
||||
|
||||
$handle = @fopen($path, 'r');
|
||||
|
||||
if (false === $handle) {
|
||||
throw new InvalidArgumentException(sprintf('File %s does not exist.', $path));
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue