updated-packages
This commit is contained in:
8
vendor/intervention/image/composer.json
vendored
8
vendor/intervention/image/composer.json
vendored
@@ -7,17 +7,17 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "Oliver Vogel",
|
||||
"email": "oliver@olivervogel.com",
|
||||
"homepage": "http://olivervogel.com/"
|
||||
"email": "oliver@intervention.io",
|
||||
"homepage": "https://intervention.io/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"ext-fileinfo": "*",
|
||||
"guzzlehttp/psr7": "~1.1"
|
||||
"guzzlehttp/psr7": "~1.1 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8 || ^5.7",
|
||||
"phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15",
|
||||
"mockery/mockery": "~0.9.2"
|
||||
},
|
||||
"suggest": {
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
abstract class AbstractColor
|
||||
{
|
||||
/**
|
||||
@@ -136,7 +139,7 @@ abstract class AbstractColor
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Color format ({$value}) cannot be read."
|
||||
);
|
||||
}
|
||||
@@ -172,7 +175,7 @@ abstract class AbstractColor
|
||||
return $this;
|
||||
|
||||
default:
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Color format ({$type}) is not supported."
|
||||
);
|
||||
}
|
||||
@@ -216,7 +219,7 @@ abstract class AbstractColor
|
||||
$result[2] = ($matches[3] >= 0 && $matches[3] <= 255) ? intval($matches[3]) : 0;
|
||||
$result[3] = ($matches[4] >= 0 && $matches[4] <= 1) ? $matches[4] : 0;
|
||||
} else {
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Unable to read color ({$value})."
|
||||
);
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Intervention\Image;
|
||||
|
||||
use GuzzleHttp\Psr7\Stream;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
abstract class AbstractDecoder
|
||||
@@ -68,8 +69,9 @@ abstract class AbstractDecoder
|
||||
$options = [
|
||||
'http' => [
|
||||
'method'=>"GET",
|
||||
'protocol_version'=>1.1, // force use HTTP 1.1 for service mesh environment with envoy
|
||||
'header'=>"Accept-language: en\r\n".
|
||||
"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2\r\n"
|
||||
"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36\r\n"
|
||||
]
|
||||
];
|
||||
|
||||
@@ -80,7 +82,7 @@ abstract class AbstractDecoder
|
||||
return $this->initFromBinary($data);
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Unable to init from given url (".$url.")."
|
||||
);
|
||||
}
|
||||
@@ -123,7 +125,7 @@ abstract class AbstractDecoder
|
||||
return $this->initFromBinary($data);
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Unable to init from given stream"
|
||||
);
|
||||
}
|
||||
@@ -139,6 +141,10 @@ abstract class AbstractDecoder
|
||||
return (get_resource_type($this->data) == 'gd');
|
||||
}
|
||||
|
||||
if ($this->data instanceof \GdImage) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -262,7 +268,7 @@ abstract class AbstractDecoder
|
||||
return false;
|
||||
}
|
||||
|
||||
return base64_encode(base64_decode($this->data)) === $this->data;
|
||||
return base64_encode(base64_decode($this->data)) === str_replace(["\n", "\r"], '', $this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,7 +295,7 @@ abstract class AbstractDecoder
|
||||
}
|
||||
|
||||
$pattern = "/^data:(?:image\/[a-zA-Z\-\.]+)(?:charset=\".+\")?;base64,(?P<data>.+)$/";
|
||||
preg_match($pattern, $data_url, $matches);
|
||||
preg_match($pattern, str_replace(["\n", "\r"], '', $data_url), $matches);
|
||||
|
||||
if (is_array($matches) && array_key_exists('data', $matches)) {
|
||||
return base64_decode($matches['data']);
|
||||
@@ -342,7 +348,7 @@ abstract class AbstractDecoder
|
||||
return $this->initFromBinary(base64_decode($this->data));
|
||||
|
||||
default:
|
||||
throw new Exception\NotReadableException("Image source not readable");
|
||||
throw new NotReadableException("Image source not readable");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
abstract class AbstractDriver
|
||||
{
|
||||
/**
|
||||
@@ -102,8 +104,12 @@ abstract class AbstractDriver
|
||||
*/
|
||||
private function getCommandClassName($name)
|
||||
{
|
||||
$name = mb_convert_case($name[0], MB_CASE_UPPER, 'utf-8') . mb_substr($name, 1, mb_strlen($name));
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
$name = mb_strtoupper(mb_substr($name, 0, 1)) . mb_substr($name, 1);
|
||||
} else {
|
||||
$name = strtoupper(substr($name, 0, 1)) . substr($name, 1);
|
||||
}
|
||||
|
||||
$drivername = $this->getDriverName();
|
||||
$classnameLocal = sprintf('\Intervention\Image\%s\Commands\%sCommand', $drivername, ucfirst($name));
|
||||
$classnameGlobal = sprintf('\Intervention\Image\Commands\%sCommand', ucfirst($name));
|
||||
@@ -114,7 +120,7 @@ abstract class AbstractDriver
|
||||
return $classnameGlobal;
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Command ({$name}) is not available for driver ({$drivername})."
|
||||
);
|
||||
}
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Intervention\Image\Exception\InvalidArgumentException;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
abstract class AbstractEncoder
|
||||
{
|
||||
/**
|
||||
@@ -81,6 +84,20 @@ abstract class AbstractEncoder
|
||||
*/
|
||||
abstract protected function processWebp();
|
||||
|
||||
/**
|
||||
* Processes and returns image as Avif encoded string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function processAvif();
|
||||
|
||||
/**
|
||||
* Processes and returns image as Heic encoded string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function processHeic();
|
||||
|
||||
/**
|
||||
* Process a given image
|
||||
*
|
||||
@@ -114,9 +131,12 @@ abstract class AbstractEncoder
|
||||
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'jfif':
|
||||
case 'image/jp2':
|
||||
case 'image/jpg':
|
||||
case 'image/jpeg':
|
||||
case 'image/pjpeg':
|
||||
case 'image/jfif':
|
||||
$this->result = $this->processJpeg();
|
||||
break;
|
||||
|
||||
@@ -129,7 +149,6 @@ abstract class AbstractEncoder
|
||||
$this->result = $this->processTiff();
|
||||
break;
|
||||
|
||||
case 'bmp':
|
||||
case 'bmp':
|
||||
case 'ms-bmp':
|
||||
case 'x-bitmap':
|
||||
@@ -165,10 +184,21 @@ abstract class AbstractEncoder
|
||||
case 'image/x-webp':
|
||||
$this->result = $this->processWebp();
|
||||
break;
|
||||
|
||||
case 'avif':
|
||||
case 'image/avif':
|
||||
$this->result = $this->processAvif();
|
||||
break;
|
||||
|
||||
case 'heic':
|
||||
case 'image/heic':
|
||||
case 'image/heif':
|
||||
$this->result = $this->processHeic();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"Encoding format ({$format}) is not supported."
|
||||
throw new NotSupportedException(
|
||||
"Encoding format ({$this->format}) is not supported."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -229,7 +259,7 @@ abstract class AbstractEncoder
|
||||
$quality = $quality === 0 ? 1 : $quality;
|
||||
|
||||
if ($quality < 0 || $quality > 100) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
'Quality must range from 0 to 100.'
|
||||
);
|
||||
}
|
||||
|
@@ -46,6 +46,13 @@ abstract class AbstractFont
|
||||
*/
|
||||
public $valign;
|
||||
|
||||
/**
|
||||
* Space between text characters
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $kerning = 0;
|
||||
|
||||
/**
|
||||
* Path to TTF or GD library internal font file of the text
|
||||
*
|
||||
@@ -62,7 +69,7 @@ abstract class AbstractFont
|
||||
* @return boolean
|
||||
*/
|
||||
abstract public function applyToImage(Image $image, $posx = 0, $posy = 0);
|
||||
|
||||
|
||||
/**
|
||||
* Calculates bounding box of current font setting
|
||||
*
|
||||
@@ -73,7 +80,7 @@ abstract class AbstractFont
|
||||
/**
|
||||
* Create a new instance of Font
|
||||
*
|
||||
* @param Strinf $text Text to be written
|
||||
* @param String $text Text to be written
|
||||
*/
|
||||
public function __construct($text = null)
|
||||
{
|
||||
@@ -84,7 +91,7 @@ abstract class AbstractFont
|
||||
* Set text to be written
|
||||
*
|
||||
* @param String $text
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
public function text($text)
|
||||
{
|
||||
@@ -107,7 +114,7 @@ abstract class AbstractFont
|
||||
* Set font size in pixels
|
||||
*
|
||||
* @param int $size
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
public function size($size)
|
||||
{
|
||||
@@ -130,7 +137,7 @@ abstract class AbstractFont
|
||||
* Set color of text to be written
|
||||
*
|
||||
* @param mixed $color
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
public function color($color)
|
||||
{
|
||||
@@ -153,7 +160,7 @@ abstract class AbstractFont
|
||||
* Set rotation angle of text
|
||||
*
|
||||
* @param int $angle
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
public function angle($angle)
|
||||
{
|
||||
@@ -176,7 +183,7 @@ abstract class AbstractFont
|
||||
* Set horizontal text alignment
|
||||
*
|
||||
* @param string $align
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
public function align($align)
|
||||
{
|
||||
@@ -199,7 +206,7 @@ abstract class AbstractFont
|
||||
* Set vertical text alignment
|
||||
*
|
||||
* @param string $valign
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
public function valign($valign)
|
||||
{
|
||||
@@ -218,11 +225,32 @@ abstract class AbstractFont
|
||||
return $this->valign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text kerning
|
||||
*
|
||||
* @param string $kerning
|
||||
* @return void
|
||||
*/
|
||||
public function kerning($kerning)
|
||||
{
|
||||
$this->kerning = $kerning;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get kerning
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getKerning()
|
||||
{
|
||||
return $this->kerning;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set path to font file
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
public function file($file)
|
||||
{
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image\Commands;
|
||||
|
||||
use Intervention\Image\Commands\Argument;
|
||||
|
||||
abstract class AbstractCommand
|
||||
{
|
||||
/**
|
||||
@@ -44,7 +46,7 @@ abstract class AbstractCommand
|
||||
*/
|
||||
public function argument($key)
|
||||
{
|
||||
return new \Intervention\Image\Commands\Argument($this, $key);
|
||||
return new Argument($this, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image\Commands;
|
||||
|
||||
use Intervention\Image\Exception\InvalidArgumentException;
|
||||
|
||||
class Argument
|
||||
{
|
||||
/**
|
||||
@@ -66,7 +68,7 @@ class Argument
|
||||
public function required()
|
||||
{
|
||||
if ( ! array_key_exists($this->key, $this->command->arguments)) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
sprintf("Missing argument %d for %s", $this->key + 1, $this->getCommandName())
|
||||
);
|
||||
}
|
||||
@@ -81,61 +83,59 @@ class Argument
|
||||
*/
|
||||
public function type($type)
|
||||
{
|
||||
$fail = false;
|
||||
|
||||
$valid = true;
|
||||
$value = $this->value();
|
||||
|
||||
if (is_null($value)) {
|
||||
if ($value === null) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
switch (strtolower($type)) {
|
||||
|
||||
case 'bool':
|
||||
case 'boolean':
|
||||
$fail = ! is_bool($value);
|
||||
$message = sprintf('%s accepts only boolean values as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||
$valid = \is_bool($value);
|
||||
$message = '%s accepts only boolean values as argument %d.';
|
||||
break;
|
||||
|
||||
case 'int':
|
||||
case 'integer':
|
||||
$fail = ! is_integer($value);
|
||||
$message = sprintf('%s accepts only integer values as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||
$valid = \is_int($value);
|
||||
$message = '%s accepts only integer values as argument %d.';
|
||||
break;
|
||||
|
||||
case 'num':
|
||||
case 'numeric':
|
||||
$fail = ! is_numeric($value);
|
||||
$message = sprintf('%s accepts only numeric values as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||
$valid = is_numeric($value);
|
||||
$message = '%s accepts only numeric values as argument %d.';
|
||||
break;
|
||||
|
||||
case 'str':
|
||||
case 'string':
|
||||
$fail = ! is_string($value);
|
||||
$message = sprintf('%s accepts only string values as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||
$valid = \is_string($value);
|
||||
$message = '%s accepts only string values as argument %d.';
|
||||
break;
|
||||
|
||||
case 'array':
|
||||
$fail = ! is_array($value);
|
||||
$message = sprintf('%s accepts only array as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||
$valid = \is_array($value);
|
||||
$message = '%s accepts only array as argument %d.';
|
||||
break;
|
||||
|
||||
case 'closure':
|
||||
$fail = ! is_a($value, '\Closure');
|
||||
$message = sprintf('%s accepts only Closure as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||
$valid = is_a($value, '\Closure');
|
||||
$message = '%s accepts only Closure as argument %d.';
|
||||
break;
|
||||
|
||||
case 'digit':
|
||||
$fail = ! $this->isDigit($value);
|
||||
$message = sprintf('%s accepts only integer values as argument %d.', $this->getCommandName(), $this->key + 1);
|
||||
$valid = $this->isDigit($value);
|
||||
$message = '%s accepts only integer values as argument %d.';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($fail) {
|
||||
if (! $valid) {
|
||||
$commandName = $this->getCommandName();
|
||||
$argument = $this->key + 1;
|
||||
|
||||
$message = isset($message) ? $message : sprintf("Missing argument for %d.", $this->key);
|
||||
if (isset($message)) {
|
||||
$message = sprintf($message, $commandName, $argument);
|
||||
} else {
|
||||
$message = sprintf('Missing argument for %d.', $argument);
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
$message
|
||||
);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class Argument
|
||||
$omega = max($x, $y);
|
||||
|
||||
if ($value < $alpha || $value > $omega) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Argument %d must be between %s and %s.', $this->key, $x, $y)
|
||||
);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ class Argument
|
||||
}
|
||||
|
||||
if ($v < $value) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Argument %d must be at least %s.', $this->key, $value)
|
||||
);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ class Argument
|
||||
}
|
||||
|
||||
if ($v > $value) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Argument %d may not be greater than %s.', $this->key, $value)
|
||||
);
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ namespace Intervention\Image\Commands;
|
||||
|
||||
use Closure;
|
||||
|
||||
class CircleCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class CircleCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Draw a circle centered on given image
|
||||
|
@@ -4,7 +4,7 @@ namespace Intervention\Image\Commands;
|
||||
|
||||
use Closure;
|
||||
|
||||
class EllipseCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class EllipseCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Draws ellipse on given image
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Commands;
|
||||
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
class ExifCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
@@ -15,8 +18,8 @@ class ExifCommand extends AbstractCommand
|
||||
*/
|
||||
public function execute($image)
|
||||
{
|
||||
if ( ! function_exists('exif_read_data')) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
if (!function_exists('exif_read_data')) {
|
||||
throw new NotSupportedException(
|
||||
"Reading Exif data is not supported by this PHP installation."
|
||||
);
|
||||
}
|
||||
@@ -24,14 +27,35 @@ class ExifCommand extends AbstractCommand
|
||||
$key = $this->argument(0)->value();
|
||||
|
||||
// try to read exif data from image file
|
||||
$data = @exif_read_data($image->dirname .'/'. $image->basename);
|
||||
try {
|
||||
if ($image->dirname && $image->basename) {
|
||||
$stream = $image->dirname . '/' . $image->basename;
|
||||
} elseif (version_compare(PHP_VERSION, '7.2.0', '>=')) {
|
||||
// https://www.php.net/manual/en/function.exif-read-data.php#refsect1-function.exif-read-data-changelog
|
||||
$stream = $image->stream()->detach();
|
||||
} else {
|
||||
// https://bugs.php.net/bug.php?id=65187
|
||||
$stream = $image->encode('data-url')->encoded;
|
||||
}
|
||||
|
||||
if (! is_null($key) && is_array($data)) {
|
||||
$data = array_key_exists($key, $data) ? $data[$key] : false;
|
||||
$data = @exif_read_data($stream);
|
||||
|
||||
if (!is_null($key) && is_array($data)) {
|
||||
$data = array_key_exists($key, $data) ? $data[$key] : false;
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw new NotReadableException(
|
||||
sprintf(
|
||||
"Cannot read the Exif data from the filename (%s) provided ",
|
||||
$image->dirname . '/' . $image->basename
|
||||
),
|
||||
$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
$this->setOutput($data);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image\Commands;
|
||||
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
class IptcCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
@@ -13,7 +15,7 @@ class IptcCommand extends AbstractCommand
|
||||
public function execute($image)
|
||||
{
|
||||
if ( ! function_exists('iptcparse')) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Reading Iptc data is not supported by this PHP installation."
|
||||
);
|
||||
}
|
||||
@@ -34,6 +36,8 @@ class IptcCommand extends AbstractCommand
|
||||
$data['Category'] = isset($iptc["2#015"][0]) ? $iptc["2#015"][0] : null;
|
||||
$data['Subcategories'] = isset($iptc["2#020"][0]) ? $iptc["2#020"][0] : null;
|
||||
$data['Keywords'] = isset($iptc["2#025"][0]) ? $iptc["2#025"] : null;
|
||||
$data['ReleaseDate'] = isset($iptc["2#030"][0]) ? $iptc["2#030"][0] : null;
|
||||
$data['ReleaseTime'] = isset($iptc["2#035"][0]) ? $iptc["2#035"][0] : null;
|
||||
$data['SpecialInstructions'] = isset($iptc["2#040"][0]) ? $iptc["2#040"][0] : null;
|
||||
$data['CreationDate'] = isset($iptc["2#055"][0]) ? $iptc["2#055"][0] : null;
|
||||
$data['CreationTime'] = isset($iptc["2#060"][0]) ? $iptc["2#060"][0] : null;
|
||||
|
@@ -4,7 +4,7 @@ namespace Intervention\Image\Commands;
|
||||
|
||||
use Closure;
|
||||
|
||||
class LineCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class LineCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Draws line on given image
|
||||
|
@@ -3,8 +3,9 @@
|
||||
namespace Intervention\Image\Commands;
|
||||
|
||||
use Closure;
|
||||
use Intervention\Image\Exception\InvalidArgumentException;
|
||||
|
||||
class PolygonCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class PolygonCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Draw a polygon on given image
|
||||
@@ -21,13 +22,13 @@ class PolygonCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
|
||||
// check if number if coordinates is even
|
||||
if ($vertices_count % 2 !== 0) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
"The number of given polygon vertices must be even."
|
||||
);
|
||||
}
|
||||
|
||||
if ($vertices_count < 6) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
"You must have at least 3 points in your array."
|
||||
);
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ namespace Intervention\Image\Commands;
|
||||
|
||||
use Closure;
|
||||
|
||||
class RectangleCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class RectangleCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Draws rectangle on given image
|
||||
|
@@ -15,11 +15,25 @@ class StreamCommand extends AbstractCommand
|
||||
{
|
||||
$format = $this->argument(0)->value();
|
||||
$quality = $this->argument(1)->between(0, 100)->value();
|
||||
$data = $image->encode($format, $quality)->getEncoded();
|
||||
|
||||
$this->setOutput(\GuzzleHttp\Psr7\stream_for(
|
||||
$image->encode($format, $quality)->getEncoded()
|
||||
));
|
||||
$this->setOutput($this->getStream($data));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stream from given data
|
||||
*
|
||||
* @param string $data
|
||||
* @return \Psr\Http\Message\StreamInterface
|
||||
*/
|
||||
protected function getStream($data)
|
||||
{
|
||||
if (class_exists(\GuzzleHttp\Psr7\Utils::class)) {
|
||||
return \GuzzleHttp\Psr7\Utils::streamFor($data); // guzzlehttp/psr7 >= 2.0
|
||||
}
|
||||
|
||||
return \GuzzleHttp\Psr7\stream_for($data); // guzzlehttp/psr7 < 2.0
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ namespace Intervention\Image\Commands;
|
||||
|
||||
use Closure;
|
||||
|
||||
class TextCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class TextCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Write text on given image
|
||||
|
@@ -4,6 +4,12 @@ namespace Intervention\Image\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* @method static \Intervention\Image\Image make(mixed $data)
|
||||
* @method static self configure(array $config)
|
||||
* @method static \Intervention\Image\Image canvas(int $width, int $height, mixed $background = null)
|
||||
* @method static \Intervention\Image\Image cache(\Closure $callback, int $lifetime = null, boolean $returnObj = false)
|
||||
*/
|
||||
class Image extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image\Filters;
|
||||
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class DemoFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
@@ -32,7 +34,7 @@ class DemoFilter implements FilterInterface
|
||||
* @param \Intervention\Image\Image $image
|
||||
* @return \Intervention\Image\Image
|
||||
*/
|
||||
public function applyFilter(\Intervention\Image\Image $image)
|
||||
public function applyFilter(Image $image)
|
||||
{
|
||||
$image->pixelate($this->size);
|
||||
$image->greyscale();
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image\Filters;
|
||||
|
||||
use Intervention\Image\Image;
|
||||
|
||||
interface FilterInterface
|
||||
{
|
||||
/**
|
||||
@@ -10,5 +12,5 @@ interface FilterInterface
|
||||
* @param \Intervention\Image\Image $image
|
||||
* @return \Intervention\Image\Image
|
||||
*/
|
||||
public function applyFilter(\Intervention\Image\Image $image);
|
||||
public function applyFilter(Image $image);
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Intervention\Image\Gd;
|
||||
|
||||
use Intervention\Image\AbstractColor;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
class Color extends AbstractColor
|
||||
{
|
||||
@@ -134,7 +135,7 @@ class Color extends AbstractColor
|
||||
*/
|
||||
public function initFromObject($value)
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"GD colors cannot init from ImagickPixel objects."
|
||||
);
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class BackupCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class BackupCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Saves a backups of current state of image core
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class BlurCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class BlurCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Applies blur effect on image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class BrightnessCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class BrightnessCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Changes image brightness
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class ColorizeCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class ColorizeCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Changes balance of different RGB color channels
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class ContrastCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class ContrastCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Changes contrast of image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class DestroyCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class DestroyCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Destroys current image core and frees up memory
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
use Intervention\Image\Gd\Decoder;
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Gd\Color;
|
||||
use Intervention\Image\Gd\Decoder;
|
||||
|
||||
class FillCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class FillCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Fills image with color or pattern
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class GammaCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class GammaCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Applies gamma correction to a given image
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Size;
|
||||
|
||||
class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class GetSizeCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Reads size of given image instance in pixels
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class GreyscaleCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class GreyscaleCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Turns an image into a greyscale version
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class InsertCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class InsertCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Insert another image into given image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class InterlaceCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class InterlaceCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Toggles interlaced encoding mode
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class InvertCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class InvertCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Inverts colors of an image
|
||||
|
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
|
||||
class LimitColorsCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Reduces colors of a given image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class MaskCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class MaskCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Applies an alpha mask to an image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class OpacityCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class OpacityCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Defines opacity of an image
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Gd\Color;
|
||||
|
||||
class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class PickColorCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Read color information from a certain position
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Gd\Color;
|
||||
|
||||
class PixelCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class PixelCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Draws one pixel to a given image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class PixelateCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class PixelateCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Applies a pixelation effect to a given image
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class ResetCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Exception\RuntimeException;
|
||||
|
||||
class ResetCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Resets given image to its backup state
|
||||
@@ -13,8 +16,9 @@ class ResetCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
public function execute($image)
|
||||
{
|
||||
$backupName = $this->argument(0)->value();
|
||||
|
||||
if (is_resource($backup = $image->getBackup($backupName))) {
|
||||
$backup = $image->getBackup($backupName);
|
||||
|
||||
if (is_resource($backup) || $backup instanceof \GdImage) {
|
||||
|
||||
// destroy current resource
|
||||
imagedestroy($image->getCore());
|
||||
@@ -28,7 +32,7 @@ class ResetCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\RuntimeException(
|
||||
throw new RuntimeException(
|
||||
"Backup not available. Call backup() before reset()."
|
||||
);
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class ResizeCanvasCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Resizes image boundaries
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class ResizeCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class ResizeCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Resizes image dimensions
|
||||
@@ -42,7 +44,7 @@ class ResizeCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
protected function modify($image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
|
||||
{
|
||||
// create new image
|
||||
$modified = imagecreatetruecolor($dst_w, $dst_h);
|
||||
$modified = imagecreatetruecolor(intval($dst_w), intval($dst_h));
|
||||
|
||||
// get current image
|
||||
$resource = $image->getCore();
|
||||
@@ -68,8 +70,8 @@ class ResizeCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
$dst_y,
|
||||
$src_x,
|
||||
$src_y,
|
||||
$dst_w,
|
||||
$dst_h,
|
||||
intval($dst_w),
|
||||
intval($dst_h),
|
||||
$src_w,
|
||||
$src_h
|
||||
);
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Gd\Color;
|
||||
|
||||
class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class RotateCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Rotates image counter clockwise
|
||||
@@ -19,7 +20,7 @@ class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
$color = new Color($color);
|
||||
|
||||
// restrict rotations beyond 360 degrees, since the end result is the same
|
||||
$angle %= 360;
|
||||
$angle = fmod($angle, 360);
|
||||
|
||||
// rotate image
|
||||
$image->setCore(imagerotate($image->getCore(), $angle, $color->getInt()));
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Commands;
|
||||
|
||||
class SharpenCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class SharpenCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Sharpen image
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image\Gd;
|
||||
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
@@ -15,7 +17,7 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
public function initFromPath($path)
|
||||
{
|
||||
if ( ! file_exists($path)) {
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Unable to find file ({$path})."
|
||||
);
|
||||
}
|
||||
@@ -46,21 +48,37 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
case 'image/webp':
|
||||
case 'image/x-webp':
|
||||
if ( ! function_exists('imagecreatefromwebp')) {
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Unsupported image type. GD/PHP installation does not support WebP format."
|
||||
);
|
||||
}
|
||||
$core = @imagecreatefromwebp($path);
|
||||
break;
|
||||
|
||||
case 'image/bmp':
|
||||
case 'image/ms-bmp':
|
||||
case 'image/x-bitmap':
|
||||
case 'image/x-bmp':
|
||||
case 'image/x-ms-bmp':
|
||||
case 'image/x-win-bitmap':
|
||||
case 'image/x-windows-bmp':
|
||||
case 'image/x-xbitmap':
|
||||
if (! function_exists('imagecreatefrombmp')) {
|
||||
throw new NotReadableException(
|
||||
"Unsupported image type. GD/PHP installation does not support BMP format."
|
||||
);
|
||||
}
|
||||
$core = @imagecreatefrombmp($path);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
"Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files."
|
||||
throw new NotReadableException(
|
||||
sprintf("Unsupported image type %s. GD driver is only able to decode JPG, PNG, GIF, BMP or WebP files.", strtolower($mime))
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($core)) {
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Unable to decode image from file ({$path})."
|
||||
);
|
||||
}
|
||||
@@ -94,7 +112,7 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
*/
|
||||
public function initFromImagick(\Imagick $object)
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Gd driver is unable to init from Imagick object."
|
||||
);
|
||||
}
|
||||
@@ -110,7 +128,7 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
$resource = @imagecreatefromstring($binary);
|
||||
|
||||
if ($resource === false) {
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Unable to init from given binary data."
|
||||
);
|
||||
}
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Gd;
|
||||
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class Driver extends \Intervention\Image\AbstractDriver
|
||||
{
|
||||
/**
|
||||
@@ -13,7 +16,7 @@ class Driver extends \Intervention\Image\AbstractDriver
|
||||
public function __construct(Decoder $decoder = null, Encoder $encoder = null)
|
||||
{
|
||||
if ( ! $this->coreAvailable()) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"GD Library extension not available with this PHP installation."
|
||||
);
|
||||
}
|
||||
@@ -34,7 +37,7 @@ class Driver extends \Intervention\Image\AbstractDriver
|
||||
{
|
||||
// create empty resource
|
||||
$core = imagecreatetruecolor($width, $height);
|
||||
$image = new \Intervention\Image\Image(new static, $core);
|
||||
$image = new Image(new static, $core);
|
||||
|
||||
// set background color
|
||||
$background = new Color($background);
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image\Gd;
|
||||
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
{
|
||||
/**
|
||||
@@ -55,15 +57,23 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as WEBP string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processWebp()
|
||||
{
|
||||
if ( ! function_exists('imagewebp')) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Webp format is not supported by PHP installation."
|
||||
);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
imagepalettetotruecolor($this->image->getCore());
|
||||
imagealphablending($this->image->getCore(), true);
|
||||
imagesavealpha($this->image->getCore(), true);
|
||||
imagewebp($this->image->getCore(), null, $this->quality);
|
||||
$this->image->mime = defined('IMAGETYPE_WEBP') ? image_type_to_mime_type(IMAGETYPE_WEBP) : 'image/webp';
|
||||
$buffer = ob_get_contents();
|
||||
@@ -79,7 +89,7 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
*/
|
||||
protected function processTiff()
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"TIFF format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
@@ -91,9 +101,19 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
*/
|
||||
protected function processBmp()
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"BMP format is not supported by Gd Driver."
|
||||
);
|
||||
if ( ! function_exists('imagebmp')) {
|
||||
throw new NotSupportedException(
|
||||
"BMP format is not supported by PHP installation."
|
||||
);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
imagebmp($this->image->getCore());
|
||||
$this->image->mime = defined('IMAGETYPE_BMP') ? image_type_to_mime_type(IMAGETYPE_BMP) : 'image/bmp';
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +123,7 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
*/
|
||||
protected function processIco()
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"ICO format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
@@ -115,8 +135,46 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
*/
|
||||
protected function processPsd()
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"PSD format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as AVIF string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processAvif()
|
||||
{
|
||||
if ( ! function_exists('imageavif')) {
|
||||
throw new NotSupportedException(
|
||||
"AVIF format is not supported by PHP installation."
|
||||
);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$resource = $this->image->getCore();
|
||||
imagepalettetotruecolor($resource);
|
||||
imagealphablending($resource, true);
|
||||
imagesavealpha($resource, true);
|
||||
imageavif($resource, null, $this->quality);
|
||||
$this->image->mime = defined('IMAGETYPE_AVIF') ? image_type_to_mime_type(IMAGETYPE_AVIF) : 'image/avif';
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as HEIC string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processHeic()
|
||||
{
|
||||
throw new NotSupportedException(
|
||||
"HEIC format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Intervention\Image\Gd;
|
||||
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class Font extends \Intervention\Image\AbstractFont
|
||||
@@ -27,7 +28,7 @@ class Font extends \Intervention\Image\AbstractFont
|
||||
$internalfont = is_numeric($internalfont) ? $internalfont : false;
|
||||
|
||||
if ( ! in_array($internalfont, [1, 2, 3, 4, 5])) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
sprintf('Internal GD font (%s) not available. Use only 1-5.', $internalfont)
|
||||
);
|
||||
}
|
||||
@@ -81,6 +82,13 @@ class Font extends \Intervention\Image\AbstractFont
|
||||
|
||||
if ($this->hasApplicableFontFile()) {
|
||||
|
||||
// imagettfbbox() converts numeric entities to their respective
|
||||
// character. Preserve any originally double encoded entities to be
|
||||
// represented as is.
|
||||
// eg: &#160; will render   rather than its character.
|
||||
$this->text = preg_replace('/&(#(?:x[a-fA-F0-9]+|[0-9]+);)/', '&\1', $this->text);
|
||||
$this->text = mb_encode_numericentity($this->text, array(0x0080, 0xffff, 0, 0xffff), 'UTF-8');
|
||||
|
||||
// get bounding box with angle 0
|
||||
$box = imagettfbbox($this->getPointSize(), 0, $this->file, $this->text);
|
||||
|
||||
@@ -252,4 +260,18 @@ class Font extends \Intervention\Image\AbstractFont
|
||||
imagestring($image->getCore(), $this->getInternalFont(), $posx, $posy, $this->text, $color->getInt());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text kerning
|
||||
*
|
||||
* @param string $kerning
|
||||
* @return void
|
||||
*/
|
||||
public function kerning($kerning)
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"Kerning is not supported by GD driver."
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Shapes;
|
||||
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Gd\Color;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class EllipseShape extends \Intervention\Image\AbstractShape
|
||||
class EllipseShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Width of ellipse in pixels
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Shapes;
|
||||
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Gd\Color;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class LineShape extends \Intervention\Image\AbstractShape
|
||||
class LineShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Starting point x-coordinate of line
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Shapes;
|
||||
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Gd\Color;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class PolygonShape extends \Intervention\Image\AbstractShape
|
||||
class PolygonShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Array of points of polygon
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Gd\Shapes;
|
||||
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Gd\Color;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class RectangleShape extends \Intervention\Image\AbstractShape
|
||||
class RectangleShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* X-Coordinate of top-left point
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Intervention\Image\Exception\NotWritableException;
|
||||
use Intervention\Image\Exception\RuntimeException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
@@ -11,7 +13,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
* @method \Intervention\Image\Image brightness(int $level) Changes the brightness of the current image by the given level. Use values between -100 for min. brightness. 0 for no change and +100 for max. brightness.
|
||||
* @method \Intervention\Image\Image cache(\Closure $callback, int $lifetime = null, boolean $returnObj = false) Method to create a new cached image instance from a Closure callback. Pass a lifetime in minutes for the callback and decide whether you want to get an Intervention Image instance as return value or just receive the image stream.
|
||||
* @method \Intervention\Image\Image canvas(int $width, int $height, mixed $bgcolor = null) Factory method to create a new empty image instance with given width and height. You can define a background-color optionally. By default the canvas background is transparent.
|
||||
* @method \Intervention\Image\Image circle(int $radius, int $x, int $y, \Closure $callback = null) Draw a circle at given x, y, coordinates with given radius. You can define the appearance of the circle by an optional closure callback.
|
||||
* @method \Intervention\Image\Image circle(int $diameter, int $x, int $y, \Closure $callback = null) Draw a circle at given x, y, coordinates with given diameter. You can define the appearance of the circle by an optional closure callback.
|
||||
* @method \Intervention\Image\Image colorize(int $red, int $green, int $blue) Change the RGB color values of the current image on the given channels red, green and blue. The input values are normalized so you have to include parameters from 100 for maximum color value. 0 for no change and -100 to take out all the certain color on the image.
|
||||
* @method \Intervention\Image\Image contrast(int $level) Changes the contrast of the current image by the given level. Use values between -100 for min. contrast 0 for no change and +100 for max. contrast.
|
||||
* @method \Intervention\Image\Image crop(int $width, int $height, int $x = null, int $y = null) Cut out a rectangular part of the current image with given width and height. Define optional x,y coordinates to move the top-left corner of the cutout to a certain position.
|
||||
@@ -40,7 +42,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
* @method \Intervention\Image\Image polygon(array $points, \Closure $callback = null) Draw a colored polygon with given points. You can define the appearance of the polygon by an optional closure callback.
|
||||
* @method \Intervention\Image\Image rectangle(int $x1, int $y1, int $x2, int $y2, \Closure $callback = null) Draw a colored rectangle on current image with top-left corner on x,y point 1 and bottom-right corner at x,y point 2. Define the overall appearance of the shape by passing a Closure callback as an optional parameter.
|
||||
* @method \Intervention\Image\Image reset(string $name = 'default') Resets all of the modifications to a state saved previously by backup under an optional name.
|
||||
* @method \Intervention\Image\Image resize(int $width, int $height = null, \Closure $callback = null) Resizes current image based on given width and/or height. To contraint the resize command, pass an optional Closure callback as third parameter.
|
||||
* @method \Intervention\Image\Image resize(int $width = null, int $height = null, \Closure $callback = null) Resizes current image based on given width and/or height. To contraint the resize command, pass an optional Closure callback as third parameter.
|
||||
* @method \Intervention\Image\Image resizeCanvas(int $width, int $height, string $anchor = 'center', boolean $relative = false, mixed $bgcolor = null) Resize the boundaries of the current image to given width and height. An anchor can be defined to determine from what point of the image the resizing is going to happen. Set the mode to relative to add or subtract the given width or height to the actual image dimensions. You can also pass a background color for the emerging area of the image.
|
||||
* @method mixed response(string $format = null, int $quality = 90) Sends HTTP response with current image in given format and quality.
|
||||
* @method \Intervention\Image\Image rotate(float $angle, mixed $bgcolor = null) Rotate the current image counter-clockwise by a given angle. Optionally define a background color for the uncovered zone after the rotation.
|
||||
@@ -124,23 +126,28 @@ class Image extends File
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $quality
|
||||
* @param string $format
|
||||
* @return \Intervention\Image\Image
|
||||
*/
|
||||
public function save($path = null, $quality = null)
|
||||
public function save($path = null, $quality = null, $format = null)
|
||||
{
|
||||
$path = is_null($path) ? $this->basePath() : $path;
|
||||
|
||||
if (is_null($path)) {
|
||||
throw new Exception\NotWritableException(
|
||||
throw new NotWritableException(
|
||||
"Can't write to undefined path."
|
||||
);
|
||||
}
|
||||
|
||||
$data = $this->encode(pathinfo($path, PATHINFO_EXTENSION), $quality);
|
||||
if ($format === null) {
|
||||
$format = pathinfo($path, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
$data = $this->encode($format, $quality);
|
||||
$saved = @file_put_contents($path, $data);
|
||||
|
||||
if ($saved === false) {
|
||||
throw new Exception\NotWritableException(
|
||||
throw new NotWritableException(
|
||||
"Can't write image data to path ({$path})"
|
||||
);
|
||||
}
|
||||
@@ -216,7 +223,7 @@ class Image extends File
|
||||
$name = is_null($name) ? 'default' : $name;
|
||||
|
||||
if ( ! $this->backupExists($name)) {
|
||||
throw new \Intervention\Image\Exception\RuntimeException(
|
||||
throw new RuntimeException(
|
||||
"Backup with name ({$name}) not available. Call backup() before reset()."
|
||||
);
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Closure;
|
||||
use Intervention\Image\Exception\MissingDependencyException;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
class ImageManager
|
||||
{
|
||||
@@ -90,7 +92,7 @@ class ImageManager
|
||||
return $imagecache->get($lifetime, $returnObj);
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\MissingDependencyException(
|
||||
throw new MissingDependencyException(
|
||||
"Please install package intervention/imagecache before running this function."
|
||||
);
|
||||
}
|
||||
@@ -110,7 +112,7 @@ class ImageManager
|
||||
return new $driverclass;
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Driver ({$drivername}) could not be instantiated."
|
||||
);
|
||||
}
|
||||
@@ -119,7 +121,7 @@ class ImageManager
|
||||
return $this->config['driver'];
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Unknown driver type."
|
||||
);
|
||||
}
|
||||
@@ -132,7 +134,7 @@ class ImageManager
|
||||
private function checkRequirements()
|
||||
{
|
||||
if ( ! function_exists('finfo_buffer')) {
|
||||
throw new \Intervention\Image\Exception\MissingDependencyException(
|
||||
throw new MissingDependencyException(
|
||||
"PHP Fileinfo extension must be installed/enabled to use Intervention Image."
|
||||
);
|
||||
}
|
||||
|
@@ -51,6 +51,7 @@ class ImageManagerStatic
|
||||
* @param mixed $data
|
||||
*
|
||||
* @return \Intervention\Image\Image
|
||||
* @throws \Intervention\Image\Exception\NotReadableException
|
||||
*/
|
||||
public static function make($data)
|
||||
{
|
||||
|
@@ -3,6 +3,8 @@
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Lumen\Application as LumenApplication;
|
||||
use Illuminate\Foundation\Application as IlluminateApplication;
|
||||
|
||||
class ImageServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -62,12 +64,12 @@ class ImageServiceProvider extends ServiceProvider
|
||||
*/
|
||||
private function getProvider()
|
||||
{
|
||||
if ($this->app instanceof \Laravel\Lumen\Application) {
|
||||
if ($this->app instanceof LumenApplication) {
|
||||
$provider = '\Intervention\Image\ImageServiceProviderLumen';
|
||||
} elseif (version_compare(\Illuminate\Foundation\Application::VERSION, '5.0', '<')) {
|
||||
} elseif (version_compare(IlluminateApplication::VERSION, '5.0', '<')) {
|
||||
$provider = '\Intervention\Image\ImageServiceProviderLaravel4';
|
||||
} else {
|
||||
$provider = '\Intervention\Image\ImageServiceProviderLaravel5';
|
||||
$provider = '\Intervention\Image\ImageServiceProviderLaravelRecent';
|
||||
}
|
||||
|
||||
return new $provider($this->app);
|
||||
|
0
vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php
vendored
Normal file → Executable file
0
vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php
vendored
Normal file → Executable file
@@ -4,7 +4,7 @@ namespace Intervention\Image;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ImageServiceProviderLaravel5 extends ServiceProvider
|
||||
class ImageServiceProviderLaravelRecent extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Determines if Intervention Imagecache is installed
|
||||
@@ -48,7 +48,7 @@ class ImageServiceProviderLaravel5 extends ServiceProvider
|
||||
|
||||
// create image
|
||||
$app->singleton('image', function ($app) {
|
||||
return new ImageManager($app['config']->get('image'));
|
||||
return new ImageManager($this->getImageConfig($app));
|
||||
});
|
||||
|
||||
$app->alias('image', 'Intervention\Image\ImageManager');
|
||||
@@ -59,7 +59,7 @@ class ImageServiceProviderLaravel5 extends ServiceProvider
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function bootstrapImageCache()
|
||||
protected function bootstrapImageCache()
|
||||
{
|
||||
$app = $this->app;
|
||||
$config = __DIR__.'/../../../../imagecache/src/config/config.php';
|
||||
@@ -77,7 +77,7 @@ class ImageServiceProviderLaravel5 extends ServiceProvider
|
||||
// imagecache route
|
||||
if (is_string(config('imagecache.route'))) {
|
||||
|
||||
$filename_pattern = '[ \w\\.\\/\\-\\@\(\)]+';
|
||||
$filename_pattern = '[ \w\\.\\/\\-\\@\(\)\=]+';
|
||||
|
||||
// route to access template applied image file
|
||||
$app['router']->get(config('imagecache.route').'/{template}/{filename}', [
|
||||
@@ -86,4 +86,21 @@ class ImageServiceProviderLaravel5 extends ServiceProvider
|
||||
])->where(['filename' => $filename_pattern]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return image configuration as array
|
||||
*
|
||||
* @param Application $app
|
||||
* @return array
|
||||
*/
|
||||
private function getImageConfig($app)
|
||||
{
|
||||
$config = $app['config']->get('image');
|
||||
|
||||
if (is_null($config)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick;
|
||||
|
||||
class Color extends \Intervention\Image\AbstractColor
|
||||
use Intervention\Image\AbstractColor;
|
||||
|
||||
class Color extends AbstractColor
|
||||
{
|
||||
/**
|
||||
* ImagickPixel containing current color information
|
||||
@@ -178,7 +180,7 @@ class Color extends \Intervention\Image\AbstractColor
|
||||
* @param int $tolerance
|
||||
* @return boolean
|
||||
*/
|
||||
public function differs(\Intervention\Image\AbstractColor $color, $tolerance = 0)
|
||||
public function differs(AbstractColor $color, $tolerance = 0)
|
||||
{
|
||||
$color_tolerance = round($tolerance * 2.55);
|
||||
$alpha_tolerance = round($tolerance);
|
||||
@@ -263,7 +265,7 @@ class Color extends \Intervention\Image\AbstractColor
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates RGA integer alpha value into float value
|
||||
* Calculates RGBA integer alpha value into float value
|
||||
*
|
||||
* @param int $value
|
||||
* @return float
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class BackupCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class BackupCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Saves a backups of current state of image core
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class BlurCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class BlurCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Applies blur effect on image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class BrightnessCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class BrightnessCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Changes image brightness
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class ColorizeCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class ColorizeCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Changes balance of different RGB color channels
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class ContrastCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class ContrastCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Changes contrast of image
|
||||
|
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Exception\InvalidArgumentException;
|
||||
use Intervention\Image\Point;
|
||||
use Intervention\Image\Size;
|
||||
|
||||
class CropCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class CropCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Crop an image instance
|
||||
@@ -21,7 +23,7 @@ class CropCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
$y = $this->argument(3)->type('digit')->value();
|
||||
|
||||
if (is_null($width) || is_null($height)) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
"Width and height of cutout needs to be defined."
|
||||
);
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class DestroyCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class DestroyCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Destroys current image core and frees up memory
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\ExifCommand as BaseCommand;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
class ExifCommand extends BaseCommand
|
||||
{
|
||||
@@ -35,7 +36,7 @@ class ExifCommand extends BaseCommand
|
||||
$core = $image->getCore();
|
||||
|
||||
if ( ! method_exists($core, 'getImageProperties')) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Reading Exif data is not supported by this PHP installation."
|
||||
);
|
||||
}
|
||||
|
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Decoder;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
use Intervention\Image\Imagick\Decoder;
|
||||
|
||||
class FillCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class FillCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Fills image with color or pattern
|
||||
@@ -27,7 +29,7 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
$source = new Decoder;
|
||||
$filling = $source->init($filling);
|
||||
|
||||
} catch (\Intervention\Image\Exception\NotReadableException $e) {
|
||||
} catch (NotReadableException $e) {
|
||||
|
||||
// set solid color filling
|
||||
$filling = new Color($filling);
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Size;
|
||||
|
||||
class FitCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class FitCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Crops and resized an image at the same time
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class FlipCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class FlipCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Mirrors an image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class GammaCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class GammaCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Applies gamma correction to a given image
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Size;
|
||||
|
||||
class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class GetSizeCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Reads size of given image instance in pixels
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class GreyscaleCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class GreyscaleCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Turns an image into a greyscale version
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class InsertCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class InsertCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Insert another image into given image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class InterlaceCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class InterlaceCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Toggles interlaced encoding mode
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class InvertCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class InvertCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Inverts colors of an image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class LimitColorsCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class LimitColorsCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Reduces colors of a given image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class MaskCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class MaskCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Applies an alpha mask to an image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class OpacityCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class OpacityCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Defines opacity of an image
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class PickColorCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Read color information from a certain position
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class PixelCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class PixelCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Draws one pixel to a given image
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class PixelateCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class PixelateCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Applies a pixelation effect to a given image
|
||||
@@ -17,7 +19,7 @@ class PixelateCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
$width = $image->getWidth();
|
||||
$height = $image->getHeight();
|
||||
|
||||
$image->getCore()->scaleImage(max(1, ($width / $size)), max(1, ($height / $size)));
|
||||
$image->getCore()->scaleImage(max(1, intval($width / $size)), max(1, intval($height / $size)));
|
||||
$image->getCore()->scaleImage($width, $height);
|
||||
|
||||
return true;
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class ResetCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Exception\RuntimeException;
|
||||
|
||||
class ResetCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Resets given image to its backup state
|
||||
@@ -30,7 +33,7 @@ class ResetCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\RuntimeException(
|
||||
throw new RuntimeException(
|
||||
"Backup not available. Call backup({$backupName}) before reset()."
|
||||
);
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class ResizeCanvasCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Resizes image boundaries
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class ResizeCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class ResizeCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Resizes image dimensions
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class RotateCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Rotates image counter clockwise
|
||||
@@ -19,7 +20,7 @@ class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
$color = new Color($color);
|
||||
|
||||
// restrict rotations beyond 360 degrees, since the end result is the same
|
||||
$angle %= 360;
|
||||
$angle = fmod($angle, 360);
|
||||
|
||||
// rotate image
|
||||
$image->getCore()->rotateImage($color->getPixel(), ($angle * -1));
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
class SharpenCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
|
||||
class SharpenCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Sharpen image
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Commands;
|
||||
|
||||
use Intervention\Image\Commands\AbstractCommand;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class TrimCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
class TrimCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* Trims away parts of an image
|
||||
|
@@ -2,9 +2,12 @@
|
||||
|
||||
namespace Intervention\Image\Imagick;
|
||||
|
||||
use Intervention\Image\AbstractDecoder;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
class Decoder extends AbstractDecoder
|
||||
{
|
||||
/**
|
||||
* Initiates new image from path in filesystem
|
||||
@@ -45,7 +48,7 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
*/
|
||||
public function initFromGdResource($resource)
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
'Imagick driver is unable to init from GD resource.'
|
||||
);
|
||||
}
|
||||
@@ -84,7 +87,7 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
$core->readImageBlob($binary);
|
||||
|
||||
} catch (\ImagickException $e) {
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
throw new NotReadableException(
|
||||
"Unable to read image from binary data.",
|
||||
0,
|
||||
$e
|
||||
|
@@ -2,7 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Imagick;
|
||||
|
||||
class Driver extends \Intervention\Image\AbstractDriver
|
||||
use Intervention\Image\AbstractDriver;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class Driver extends AbstractDriver
|
||||
{
|
||||
/**
|
||||
* Creates new instance of driver
|
||||
@@ -13,7 +17,7 @@ class Driver extends \Intervention\Image\AbstractDriver
|
||||
public function __construct(Decoder $decoder = null, Encoder $encoder = null)
|
||||
{
|
||||
if ( ! $this->coreAvailable()) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"ImageMagick module not available with this PHP installation."
|
||||
);
|
||||
}
|
||||
@@ -42,7 +46,7 @@ class Driver extends \Intervention\Image\AbstractDriver
|
||||
$core->setColorspace(\Imagick::COLORSPACE_UNDEFINED);
|
||||
|
||||
// build image
|
||||
$image = new \Intervention\Image\Image(new static, $core);
|
||||
$image = new Image(new static, $core);
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace Intervention\Image\Imagick;
|
||||
|
||||
class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
use Intervention\Image\AbstractEncoder;
|
||||
use Intervention\Image\Exception\NotSupportedException;
|
||||
|
||||
class Encoder extends AbstractEncoder
|
||||
{
|
||||
/**
|
||||
* Processes and returns encoded image as JPEG string
|
||||
@@ -44,6 +47,8 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_PNG);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -63,13 +68,15 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_GIF);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
protected function processWebp()
|
||||
{
|
||||
if ( ! \Imagick::queryFormats('WEBP')) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
throw new NotSupportedException(
|
||||
"Webp format is not supported by Imagick installation."
|
||||
);
|
||||
}
|
||||
@@ -78,6 +85,8 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
$compression = \Imagick::COMPRESSION_JPEG;
|
||||
|
||||
$imagick = $this->image->getCore();
|
||||
$imagick->setImageBackgroundColor(new \ImagickPixel('transparent'));
|
||||
|
||||
$imagick = $imagick->mergeImageLayers(\Imagick::LAYERMETHOD_MERGE);
|
||||
$imagick->setFormat($format);
|
||||
$imagick->setImageFormat($format);
|
||||
@@ -106,6 +115,8 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
$imagick->setCompressionQuality($this->quality);
|
||||
$imagick->setImageCompressionQuality($this->quality);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_TIFF_II);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -125,6 +136,8 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_BMP);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -144,6 +157,8 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_ICO);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -163,6 +178,62 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_PSD);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as AVIF string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processAvif()
|
||||
{
|
||||
if ( ! \Imagick::queryFormats('AVIF')) {
|
||||
throw new NotSupportedException(
|
||||
"AVIF format is not supported by Imagick installation."
|
||||
);
|
||||
}
|
||||
|
||||
$format = 'avif';
|
||||
$compression = \Imagick::COMPRESSION_UNDEFINED;
|
||||
|
||||
$imagick = $this->image->getCore();
|
||||
$imagick->setFormat($format);
|
||||
$imagick->setImageFormat($format);
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
$imagick->setCompressionQuality($this->quality);
|
||||
$imagick->setImageCompressionQuality($this->quality);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as HEIC string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processHeic()
|
||||
{
|
||||
if ( ! \Imagick::queryFormats('HEIC')) {
|
||||
throw new NotSupportedException(
|
||||
"HEIC format is not supported by Imagick installation."
|
||||
);
|
||||
}
|
||||
|
||||
$format = 'heic';
|
||||
$compression = \Imagick::COMPRESSION_UNDEFINED;
|
||||
|
||||
$imagick = $this->image->getCore();
|
||||
$imagick->setFormat($format);
|
||||
$imagick->setImageFormat($format);
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
$imagick->setCompressionQuality($this->quality);
|
||||
$imagick->setImageCompressionQuality($this->quality);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Imagick;
|
||||
|
||||
use Intervention\Image\AbstractFont;
|
||||
use Intervention\Image\Exception\RuntimeException;
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class Font extends \Intervention\Image\AbstractFont
|
||||
class Font extends AbstractFont
|
||||
{
|
||||
/**
|
||||
* Draws font to given image at given position
|
||||
@@ -25,7 +27,7 @@ class Font extends \Intervention\Image\AbstractFont
|
||||
if ($this->hasApplicableFontFile()) {
|
||||
$draw->setFont($this->file);
|
||||
} else {
|
||||
throw new \Intervention\Image\Exception\RuntimeException(
|
||||
throw new RuntimeException(
|
||||
"Font file must be provided to apply text to image."
|
||||
);
|
||||
}
|
||||
@@ -35,6 +37,7 @@ class Font extends \Intervention\Image\AbstractFont
|
||||
|
||||
$draw->setFontSize($this->size);
|
||||
$draw->setFillColor($color->getPixel());
|
||||
$draw->setTextKerning($this->kerning);
|
||||
|
||||
// align horizontal
|
||||
switch (strtolower($this->align)) {
|
||||
@@ -56,18 +59,19 @@ class Font extends \Intervention\Image\AbstractFont
|
||||
// align vertical
|
||||
if (strtolower($this->valign) != 'bottom') {
|
||||
|
||||
// calculate box size
|
||||
$dimensions = $image->getCore()->queryFontMetrics($draw, $this->text);
|
||||
|
||||
// corrections on y-position
|
||||
switch (strtolower($this->valign)) {
|
||||
case 'center':
|
||||
case 'middle':
|
||||
// calculate box size
|
||||
$dimensions = $image->getCore()->queryFontMetrics($draw, $this->text);
|
||||
$posy = $posy + $dimensions['textHeight'] * 0.65 / 2;
|
||||
break;
|
||||
|
||||
case 'top':
|
||||
$posy = $posy + $dimensions['textHeight'] * 0.65;
|
||||
// calculate box size
|
||||
$dimensions = $image->getCore()->queryFontMetrics($draw, $this->text, false);
|
||||
$posy = $posy + $dimensions['characterHeight'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +98,7 @@ class Font extends \Intervention\Image\AbstractFont
|
||||
if ($this->hasApplicableFontFile()) {
|
||||
$draw->setFont($this->file);
|
||||
} else {
|
||||
throw new \Intervention\Image\Exception\RuntimeException(
|
||||
throw new RuntimeException(
|
||||
"Font file must be provided to apply text to image."
|
||||
);
|
||||
}
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class EllipseShape extends \Intervention\Image\AbstractShape
|
||||
class EllipseShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Width of ellipse in pixels
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class LineShape extends \Intervention\Image\AbstractShape
|
||||
class LineShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Starting point x-coordinate of line
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class PolygonShape extends \Intervention\Image\AbstractShape
|
||||
class PolygonShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Array of points of polygon
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class RectangleShape extends \Intervention\Image\AbstractShape
|
||||
class RectangleShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* X-Coordinate of top-left point
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Illuminate\Support\Facades\Response as IlluminateResponse;
|
||||
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||
|
||||
class Response
|
||||
{
|
||||
/**
|
||||
@@ -53,10 +56,16 @@ class Response
|
||||
|
||||
if (function_exists('app') && is_a($app = app(), 'Illuminate\Foundation\Application')) {
|
||||
|
||||
$response = \Illuminate\Support\Facades\Response::make($data);
|
||||
$response = IlluminateResponse::make($data);
|
||||
$response->header('Content-Type', $mime);
|
||||
$response->header('Content-Length', $length);
|
||||
|
||||
} elseif (class_exists('\Symfony\Component\HttpFoundation\Response')) {
|
||||
|
||||
$response = new SymfonyResponse($data);
|
||||
$response->headers->set('Content-Type', $mime);
|
||||
$response->headers->set('Content-Length', $length);
|
||||
|
||||
} else {
|
||||
|
||||
header('Content-Type: ' . $mime);
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Closure;
|
||||
use Intervention\Image\Exception\InvalidArgumentException;
|
||||
|
||||
class Size
|
||||
{
|
||||
@@ -70,7 +71,7 @@ class Size
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
return intval($this->width);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +81,7 @@ class Size
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
return intval($this->height);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +105,7 @@ class Size
|
||||
public function resize($width, $height, Closure $callback = null)
|
||||
{
|
||||
if (is_null($width) && is_null($height)) {
|
||||
throw new \Intervention\Image\Exception\InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
"Width or height needs to be defined."
|
||||
);
|
||||
}
|
||||
@@ -154,7 +155,7 @@ class Size
|
||||
}
|
||||
|
||||
if ($constraint->isFixed(Constraint::ASPECTRATIO)) {
|
||||
$h = intval(round($this->width / $constraint->getSize()->getRatio()));
|
||||
$h = max(1, intval(round($this->width / $constraint->getSize()->getRatio())));
|
||||
|
||||
if ($constraint->isFixed(Constraint::UPSIZE)) {
|
||||
$this->height = ($h > $max_height) ? $max_height : $h;
|
||||
@@ -190,7 +191,7 @@ class Size
|
||||
}
|
||||
|
||||
if ($constraint->isFixed(Constraint::ASPECTRATIO)) {
|
||||
$w = intval(round($this->height * $constraint->getSize()->getRatio()));
|
||||
$w = max(1, intval(round($this->height * $constraint->getSize()->getRatio())));
|
||||
|
||||
if ($constraint->isFixed(Constraint::UPSIZE)) {
|
||||
$this->width = ($w > $max_width) ? $max_width : $w;
|
||||
@@ -337,8 +338,8 @@ class Size
|
||||
case 'middle':
|
||||
case 'center-center':
|
||||
case 'middle-middle':
|
||||
$x = intval($this->width / 2);
|
||||
$y = intval($this->height / 2);
|
||||
$x = intval($this->width / 2) + $offset_x;
|
||||
$y = intval($this->height / 2) + $offset_y;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user