src/ImageStream.php
private function setResource(ImageResourceInterface $image)
    {
        $error = null;

        if ($image->isLocal()) {
            set_error_handler(function ($e, $msg) use (&$error) {
                $error = $msg;
            }, E_WARNING);

            $resource = fopen($image->getPath(), 'r');
            restore_error_handler();
        } else {
            $resource = fopen('php://temp', 'wb+');
            fwrite($resource, $image->getContents());
            rewind($resource);
        }

        if (null !== $error) {
            throw new InvalidArgumentException($error);
        }

        return $this->resource = $resource;
    }
private function setResource(ImageResourceInterface $image)
    {
        $error = null;

        if ($image->isLocal()) {
            set_error_handler(function ($e, $msg) use (&$error) {
                $error = $msg;
            }, E_WARNING);

            $resource = fopen($image->getPath(), 'r');
            restore_error_handler();
        } else {
            $resource = fopen('php://temp', 'wb+');
            fwrite($resource, $image->getContents());
            rewind($resource);
        }

        if (null !== $error) {
            throw new InvalidArgumentException($error);
        }

        return $this->resource = $resource;
    }
setResource

@param ImageResourceInterface $image

@return resource