Pimcore\Image\Adapter\ImageMagick::load PHP Метод

load() публичный Метод

loads the image by the specified path
public load ( $imagePath, array $options = [] ) : ImageMagick
$imagePath
$options array
Результат ImageMagick
    public function load($imagePath, $options = [])
    {
        // support image URLs
        if (preg_match("@^https?://@", $imagePath)) {
            $tmpFilename = "imagick_auto_download_" . md5($imagePath) . "." . File::getFileExtension($imagePath);
            $tmpFilePath = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/" . $tmpFilename;
            $this->tmpFiles[] = $tmpFilePath;
            File::put($tmpFilePath, \Pimcore\Tool::getHttpData($imagePath));
            $imagePath = $tmpFilePath;
        }
        if (!stream_is_local($imagePath)) {
            // imagick is only able to deal with local files
            // if your're using custom stream wrappers this wouldn't work, so we create a temp. local copy
            $tmpFilePath = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/imagick-tmp-" . uniqid() . "." . File::getFileExtension($imagePath);
            copy($imagePath, $tmpFilePath);
            $imagePath = $tmpFilePath;
            $this->tmpFiles[] = $imagePath;
        }
        $this->imagePath = $imagePath;
        $this->initResource();
        $this->setModified(false);
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Creates the tmp image, that image will be automatically deleted when the process finishes.
  *
  * @param $imagePath
  * @param $suffix
  * @return ImageMagick
  */
 protected function createTmpImage($imagePath, $suffix)
 {
     //if a specified file as a overlay exists
     $tmpImage = new ImageMagick();
     $tmpImage->load($imagePath);
     //creates the temp file for the background
     $this->setTmpPaths($tmpImage, $suffix);
     $this->tmpFiles[] = $tmpImage->getOutputPath();
     return $tmpImage;
 }