Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function getImageRawData($width = false, $height = false)
 {
     if (!$this->supportsImageUrl()) {
         throw new Exception('Image url is not supported by "' . basename(get_class($this)) . '" class!');
     }
     if (!$this->getImageUrl()) {
         throw new Exception('Image url is empty');
     }
     $rawImage = $this->service->httpRequest($this->getImageUrl(), [], [], 'GET');
     $image = Image::fromData($rawImage);
     if ($width or $height) {
         /** @noinspection PhpUndefinedMethodInspection */
         $image->resize($width ? $width : null, $height ? $height : null);
     }
     try {
         return $image->get();
     } catch (\Exception $e) {
         throw new Exception('Exception occurred  during saving image: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }