mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
This commit is contained in:
parent
0a49027840
commit
5701609857
6 changed files with 34 additions and 17 deletions
|
|
@ -253,7 +253,8 @@ class Http
|
||||||
403 => 'Forbidden',
|
403 => 'Forbidden',
|
||||||
404 => 'Not Found',
|
404 => 'Not Found',
|
||||||
405 => 'Method Not Allowed',
|
405 => 'Method Not Allowed',
|
||||||
416 => 'Requested range not satisfiable'
|
416 => 'Requested range not satisfiable',
|
||||||
|
500 => 'Internal Server Error'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sHeaderText = (0 === \strlen($sCustomStatusText) && isset($aStatus[$iStatus]) ? $aStatus[$iStatus] : $sCustomStatusText);
|
$sHeaderText = (0 === \strlen($sCustomStatusText) && isset($aStatus[$iStatus]) ? $aStatus[$iStatus] : $sCustomStatusText);
|
||||||
|
|
|
||||||
|
|
@ -207,37 +207,32 @@ trait Raw
|
||||||
if (!$bDownload)
|
if (!$bDownload)
|
||||||
{
|
{
|
||||||
$bDetectImageOrientation = !!$self->Config()->Get('labs', 'detect_image_exif_orientation', false);
|
$bDetectImageOrientation = !!$self->Config()->Get('labs', 'detect_image_exif_orientation', false);
|
||||||
if ($bThumbnail)
|
try
|
||||||
{
|
{
|
||||||
try
|
if ($bThumbnail)
|
||||||
{
|
{
|
||||||
$oImage = static::loadImage($rResource, $bDetectImageOrientation, 60);
|
$oImage = static::loadImage($rResource, $bDetectImageOrientation, 60);
|
||||||
\header('Content-Disposition: inline; '.
|
\header('Content-Disposition: inline; '.
|
||||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileName.'_thumb60x60.png')));
|
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileName.'_thumb60x60.png')));
|
||||||
$oImage->show('png');
|
$oImage->show('png');
|
||||||
// $oImage->show('webp'); // Little Britain: "Safari says NO"
|
// $oImage->show('webp'); // Little Britain: "Safari says NO"
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
else if ($bDetectImageOrientation &&
|
||||||
{
|
\in_array($sContentType, array('image/png', 'image/jpeg', 'image/jpg', 'image/webp')))
|
||||||
$self->Logger()->WriteExceptionShort($oException);
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else if ($bDetectImageOrientation &&
|
|
||||||
\in_array($sContentType, array('image/png', 'image/jpeg', 'image/jpg', 'image/webp')))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
$oImage = static::loadImage($rResource, $bDetectImageOrientation);
|
$oImage = static::loadImage($rResource, $bDetectImageOrientation);
|
||||||
\header('Content-Disposition: inline; '.
|
\header('Content-Disposition: inline; '.
|
||||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileName)));
|
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileName)));
|
||||||
$oImage->show();
|
$oImage->show();
|
||||||
// $oImage->show('webp'); // Little Britain: "Safari says NO"
|
// $oImage->show('webp'); // Little Britain: "Safari says NO"
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
}
|
||||||
{
|
catch (\Throwable $oException)
|
||||||
$self->Logger()->WriteExceptionShort($oException);
|
{
|
||||||
}
|
$self->Logger()->WriteExceptionShort($oException);
|
||||||
|
\MailSo\Base\Http::StatusHeader(500);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -306,6 +301,10 @@ trait Raw
|
||||||
$handler = 'SnappyMail\\Image\\'.$handler.'::createFromStream';
|
$handler = 'SnappyMail\\Image\\'.$handler.'::createFromStream';
|
||||||
$oImage = $handler($resource);
|
$oImage = $handler($resource);
|
||||||
|
|
||||||
|
if (!$oImage->valid()) {
|
||||||
|
throw new \Exception('Loading image failed');
|
||||||
|
}
|
||||||
|
|
||||||
// rotateImageByOrientation
|
// rotateImageByOrientation
|
||||||
if ($bDetectImageOrientation) {
|
if ($bDetectImageOrientation) {
|
||||||
switch ($oImage->getOrientation())
|
switch ($oImage->getOrientation())
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,6 @@ interface Image
|
||||||
public function rotate(float $degrees) : bool;
|
public function rotate(float $degrees) : bool;
|
||||||
|
|
||||||
public function show(?string $format = null) : void;
|
public function show(?string $format = null) : void;
|
||||||
|
|
||||||
|
public function valid() : bool;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@ class GD2 implements \SnappyMail\Image
|
||||||
return $this->getImageBlob();
|
return $this->getImageBlob();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function valid() : bool
|
||||||
|
{
|
||||||
|
return $this->img && 0 < \imagesx($this->img);
|
||||||
|
}
|
||||||
|
|
||||||
public static function createFromString(string &$data)
|
public static function createFromString(string &$data)
|
||||||
{
|
{
|
||||||
if (!($imginfo = \getimagesizefromstring($data))) {
|
if (!($imginfo = \getimagesizefromstring($data))) {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@ class GMagick extends \Gmagick implements \SnappyMail\Image
|
||||||
$this->clear();
|
$this->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function valid() : bool
|
||||||
|
{
|
||||||
|
return 0 < $this->getImageWidth();
|
||||||
|
}
|
||||||
|
|
||||||
public static function createFromString(string &$data)
|
public static function createFromString(string &$data)
|
||||||
{
|
{
|
||||||
$gmagick = new static();
|
$gmagick = new static();
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ class IMagick extends \Imagick implements \SnappyMail\Image
|
||||||
$this->clear();
|
$this->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function valid() : bool
|
||||||
|
{
|
||||||
|
return 0 < $this->getImageWidth();
|
||||||
|
}
|
||||||
|
|
||||||
public static function createFromString(string &$data)
|
public static function createFromString(string &$data)
|
||||||
{
|
{
|
||||||
$imagick = new static();
|
$imagick = new static();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue