mirror of
https://github.com/e107inc/e107.git
synced 2025-08-19 21:02:09 +02:00
Intervention updated to v2.6.1
PHPMailer updated to v6.5.1
This commit is contained in:
@@ -14,10 +14,10 @@
|
||||
"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": {
|
||||
|
@@ -69,6 +69,7 @@ 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"
|
||||
]
|
||||
@@ -140,6 +141,10 @@ abstract class AbstractDecoder
|
||||
return (get_resource_type($this->data) == 'gd');
|
||||
}
|
||||
|
||||
if ($this->data instanceof \GdImage) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -290,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']);
|
||||
|
@@ -104,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));
|
||||
|
@@ -84,6 +84,13 @@ abstract class AbstractEncoder
|
||||
*/
|
||||
abstract protected function processWebp();
|
||||
|
||||
/**
|
||||
* Processes and returns image as Avif encoded string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function processAvif();
|
||||
|
||||
/**
|
||||
* Process a given image
|
||||
*
|
||||
@@ -117,9 +124,11 @@ abstract class AbstractEncoder
|
||||
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'image/jp2':
|
||||
case 'image/jpg':
|
||||
case 'image/jpeg':
|
||||
case 'image/pjpeg':
|
||||
case 'image/jfif':
|
||||
$this->result = $this->processJpeg();
|
||||
break;
|
||||
|
||||
@@ -168,10 +177,15 @@ abstract class AbstractEncoder
|
||||
case 'image/x-webp':
|
||||
$this->result = $this->processWebp();
|
||||
break;
|
||||
|
||||
case 'avif':
|
||||
case 'image/avif':
|
||||
$this->result = $this->processAvif();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(
|
||||
"Encoding format ({$format}) is not supported."
|
||||
"Encoding format ({$this->format}) is not supported."
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
*
|
||||
@@ -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)
|
||||
{
|
||||
@@ -218,6 +225,27 @@ 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
|
||||
*
|
||||
|
@@ -28,7 +28,17 @@ class ExifCommand extends AbstractCommand
|
||||
|
||||
// try to read exif data from image file
|
||||
try {
|
||||
$data = @exif_read_data($image->dirname . '/' . $image->basename);
|
||||
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;
|
||||
}
|
||||
|
||||
$data = @exif_read_data($stream);
|
||||
|
||||
if (!is_null($key) && is_array($data)) {
|
||||
$data = array_key_exists($key, $data) ? $data[$key] : false;
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ class RotateCommand extends 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()));
|
||||
|
@@ -55,9 +55,25 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
$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 NotReadableException(
|
||||
"Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files."
|
||||
sprintf("Unsupported image type %s. GD driver is only able to decode JPG, PNG, GIF, BMP or WebP files.", strtolower($mime))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -66,6 +66,9 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -93,9 +96,19 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
*/
|
||||
protected function processBmp()
|
||||
{
|
||||
throw new 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,4 +134,16 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
"PSD format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as AVIF string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processAvif()
|
||||
{
|
||||
throw new NotSupportedException(
|
||||
"AVIF format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -82,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);
|
||||
|
||||
@@ -253,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."
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ class ImageServiceProviderLaravelRecent 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}', [
|
||||
|
@@ -20,7 +20,7 @@ class RotateCommand extends 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));
|
||||
|
@@ -47,6 +47,8 @@ class Encoder extends AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_PNG);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -66,6 +68,8 @@ class Encoder extends AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_GIF);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -111,6 +115,8 @@ class Encoder extends AbstractEncoder
|
||||
$imagick->setCompressionQuality($this->quality);
|
||||
$imagick->setImageCompressionQuality($this->quality);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_TIFF_II);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -130,6 +136,8 @@ class Encoder extends AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_BMP);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -149,6 +157,8 @@ class Encoder extends AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_ICO);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
@@ -168,6 +178,30 @@ class Encoder extends AbstractEncoder
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
$this->image->mime = image_type_to_mime_type(IMAGETYPE_PSD);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@@ -37,6 +37,7 @@ class Font extends AbstractFont
|
||||
|
||||
$draw->setFontSize($this->size);
|
||||
$draw->setFillColor($color->getPixel());
|
||||
$draw->setTextKerning($this->kerning);
|
||||
|
||||
// align horizontal
|
||||
switch (strtolower($this->align)) {
|
||||
@@ -70,7 +71,7 @@ class Font extends AbstractFont
|
||||
case 'top':
|
||||
// calculate box size
|
||||
$dimensions = $image->getCore()->queryFontMetrics($draw, $this->text, false);
|
||||
$posy = $posy + $dimensions['textHeight'] * 0.65;
|
||||
$posy = $posy + $dimensions['characterHeight'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -338,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