• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/File/Image/Imagick.php
  • Класс: BitrixMainFileImageImagick
  • Вызов: Imagick::load
public function load()
{
	$this->clear();

	try
	{
		$this->image = new Imagick();

		$info = $this->getInfo();
		if (!$info)
		{
			return false;
		}

		if ($this->exceedsMaxSize())
		{
			// the image exceeds maximum sizes, optionally substitute it
			return $this->substituteImage();
		}

		$needResize = false;
		if ($info->getFormat() == FileImage::FORMAT_JPEG)
		{
			// only for JPEGs
			$needResize = $this->setJpegOptions();
		}

		$allowAnimated = (isset($this->options["allowAnimatedImages"]) && $this->options["allowAnimatedImages"] === true);

		// read only the first frame
		$suffix = ($allowAnimated ? '' : '[0]');

		$this->image->readImage($this->file . $suffix);

		if ($needResize)
		{
			// JPEG memory usage optimization
			$this->image->thumbnailImage($this->jpegSize->getWidth(), $this->jpegSize->getHeight());
		}

		if ($allowAnimated && $this->image->getNumberImages() > 1)
		{
			$this->animated = true;
			$this->image = $this->image->coalesceImages();
		}

		return true;
	}
	catch (ImagickException $e)
	{
		return false;
	}
}