ensureResource example

        if (empty($this->resource) && $quality === 100) {
            if ($original === null) {
                return true;
            }

            $name = basename($target);
            $path = pathinfo($target, PATHINFO_DIRNAME);

            return $this->image()->copy($path$name);
        }

        $this->ensureResource();

        // Copy the file through ImageMagick so that it has         // a chance to convert file format.         $action = escapeshellarg($this->resource) . ' ' . escapeshellarg($target);

        $this->process($action$quality);

        unlink($this->resource);

        return true;
    }

    
        if (empty($this->resource) && $quality === 100) {
            if ($original === null) {
                return true;
            }

            $name = basename($target);
            $path = pathinfo($target, PATHINFO_DIRNAME);

            return $this->image()->copy($path$name);
        }

        $this->ensureResource();

        // for png and webp we can actually preserve transparency         if (in_array($this->image()->imageType, $this->supportTransparency, true)) {
            imagealphablending($this->resource, false);
            imagesavealpha($this->resource, true);
        }

        switch ($this->image()->imageType) {
            case IMAGETYPE_GIF:
                if (function_exists('imagegif')) {
                    throw ImageException::forInvalidImageCreate(lang('Images.gifNotSupported'));
                }


    /** * Returns the temporary image used during the image processing. * Good for extending the system or doing things this library * is not intended to do. * * @return resource */
    public function getResource()
    {
        $this->ensureResource();

        return $this->resource;
    }

    /** * Load the temporary image used during the image processing. * Some functions e.g. save() will only copy and not compress * your image otherwise. * * @return $this */
    
Home | Imprint | This part of the site doesn't use cookies.