芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/bd.mgaplay.com.br/lib/Service/ImageProcessingService.php
. */ namespace Xibo\Service; use Xibo\Service\ImageProcessingServiceInterface; use Intervention\Image\Exception\NotReadableException; use Intervention\Image\ImageManagerStatic as Img; /** * Class ImageProcessingService * @package Xibo\Service */ class ImageProcessingService implements ImageProcessingServiceInterface { /** @var LogServiceInterface */ private $log; /** * @inheritdoc */ public function __construct() { } /** * @inheritdoc */ public function setDependencies($log) { $this->log = $log; return $this; } /** @inheritdoc */ public function resizeImage($filePath, $width, $height) { try { Img::configure(array('driver' => 'gd')); $img = Img::make($filePath); $img->resize($width, $height, function ($constraint) { $constraint->aspectRatio(); }); $img->save($filePath); $img->destroy(); } catch (NotReadableException $notReadableException) { $this->log->error('Image not readable: ' . $notReadableException->getMessage()); } return $filePath; } }