X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObject%2FImage.php;h=5cef75180bdb2949f4fac96c903a07bb81d28342;hb=55369613d46eda72d5e120d5cf66703867eb03e3;hp=2ae43520ed6b9032e5070a2aeddfe196feaa3049;hpb=38a5358bfa646ae13a4a1a385741890fa88d9b7f;p=friendica.git diff --git a/src/Object/Image.php b/src/Object/Image.php index 2ae43520ed..5cef75180b 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -1,6 +1,6 @@ getType()) { case "image/png": $quality = DI::config()->get('system', 'png_quality'); - if ((! $quality) || ($quality > 9)) { - $quality = PNG_QUALITY; - } /* * From http://www.imagemagick.org/script/command-line-options.php#quality: * @@ -150,9 +147,6 @@ class Image break; case "image/jpeg": $quality = DI::config()->get('system', 'jpeg_quality'); - if ((! $quality) || ($quality > 100)) { - $quality = JPEG_QUALITY; - } $this->image->setCompressionQuality($quality); } @@ -230,9 +224,13 @@ class Image } if ($this->isImagick()) { - /* Clean it */ - $this->image = $this->image->deconstructImages(); - return $this->image; + try { + /* Clean it */ + $this->image = $this->image->deconstructImages(); + return $this->image; + } catch (Exception $e) { + return false; + } } return $this->image; } @@ -633,24 +631,6 @@ class Image $this->height = imagesy($this->image); } - /** - * @param string $path file path - * @return mixed - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - */ - public function saveToFilePath($path) - { - if (!$this->isValid()) { - return false; - } - - $string = $this->asString(); - - $stamp1 = microtime(true); - file_put_contents($path, $string); - DI::profiler()->saveTimestamp($stamp1, "file"); - } - /** * Magic method allowing string casting of an Image object * @@ -676,10 +656,14 @@ class Image } if ($this->isImagick()) { - /* Clean it */ - $this->image = $this->image->deconstructImages(); - $string = $this->image->getImagesBlob(); - return $string; + try { + /* Clean it */ + $this->image = $this->image->deconstructImages(); + $string = $this->image->getImagesBlob(); + return $string; + } catch (Exception $e) { + return false; + } } ob_start(); @@ -690,16 +674,10 @@ class Image switch ($this->getType()) { case "image/png": $quality = DI::config()->get('system', 'png_quality'); - if ((!$quality) || ($quality > 9)) { - $quality = PNG_QUALITY; - } imagepng($this->image, null, $quality); break; case "image/jpeg": $quality = DI::config()->get('system', 'jpeg_quality'); - if ((!$quality) || ($quality > 100)) { - $quality = JPEG_QUALITY; - } imagejpeg($this->image, null, $quality); } $string = ob_get_contents(); @@ -707,49 +685,4 @@ class Image return $string; } - - /** - * supported mimetypes and corresponding file extensions - * - * @return array - * @deprecated in version 2019.12 please use Util\Images::supportedTypes() instead. - */ - public static function supportedTypes() - { - return Images::supportedTypes(); - } - - /** - * Maps Mime types to Imagick formats - * - * @return array With with image formats (mime type as key) - * @deprecated in version 2019.12 please use Util\Images::getFormatsMap() instead. - */ - public static function getFormatsMap() - { - return Images::getFormatsMap(); - } - - /** - * @param string $url url - * @return array - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - * @deprecated in version 2019.12 please use Util\Images::getInfoFromURLCached() instead. - */ - public static function getInfoFromURL($url) - { - return Images::getInfoFromURLCached($url); - } - - /** - * @param integer $width width - * @param integer $height height - * @param integer $max max - * @return array - * @deprecated in version 2019.12 please use Util\Images::getScalingDimensions() instead. - */ - public static function getScalingDimensions($width, $height, $max) - { - return Images::getScalingDimensions($width, $height, $max); - } }