driver = $this->resolveDriver($driver, ...$options); } /** * {@inheritdoc} * * @see ImageManagerInterface::usingDriver() * * @throws InvalidArgumentException */ public static function usingDriver(string|DriverInterface $driver, mixed ...$options): ImageManagerInterface { return new self(self::resolveDriver($driver, ...$options)); } /** * {@inheritdoc} * * @see ImageManagerInterface::createImage() * * @throws InvalidArgumentException * @throws DriverException */ public function createImage( int $width, int $height, null|callable|AnimationFactoryInterface $animation = null, ): ImageInterface { if ($animation instanceof AnimationFactoryInterface) { return $animation->image($this->driver); } if (is_callable($animation)) { return AnimationFactory::build($width, $height, $animation, $this->driver); } return $this->driver->createImage($width, $height); } /** * {@inheritdoc} * * @see ImageManagerInterface::decode() * * @throws InvalidArgumentException * @throws ImageDecoderException * @throws DriverException */ public function decode(mixed $source, null|string|array|DecoderInterface $decoders = null): ImageInterface { return $this->driver->decodeImage( $source, in_array(gettype($decoders), ['string', 'object']) ? [$decoders] : $decoders, ); } /** * {@inheritdoc} * * @see ImageManagerInterface::decodePath() * * @throws InvalidArgumentException * @throws ImageDecoderException * @throws DriverException */ public function decodePath(string|Stringable $path): ImageInterface { return $this->decode($path, FilePathImageDecoder::class); } /** * {@inheritdoc} * * @see ImageManagerInterface::decodeBinary() * * @throws InvalidArgumentException * @throws ImageDecoderException * @throws DriverException */ public function decodeBinary(string|Stringable $binary): ImageInterface { return $this->decode($binary, BinaryImageDecoder::class); } /** * {@inheritdoc} * * @see ImageManagerInterface::decodeSplFileInfo() * * @throws InvalidArgumentException * @throws ImageDecoderException * @throws DriverException */ public function decodeSplFileInfo(SplFileInfo $splFileInfo): ImageInterface { return $this->decode($splFileInfo, SplFileInfoImageDecoder::class); } /** * {@inheritdoc} * * @see ImageManagerInterface::decodeBase64() * * @throws InvalidArgumentException * @throws ImageDecoderException * @throws DriverException */ public function decodeBase64(string|Stringable $base64): ImageInterface { return $this->decode($base64, Base64ImageDecoder::class); } /** * {@inheritdoc} * * @see ImageManagerInterface::decodeDataUri() * * @throws InvalidArgumentException * @throws ImageDecoderException * @throws DriverException */ public function decodeDataUri(string|Stringable|DataUriInterface $dataUri): ImageInterface { return $this->decode($dataUri, DataUriImageDecoder::class); } /** * {@inheritdoc} * * @see ImageManagerInterface::decodeStream() * * @throws InvalidArgumentException * @throws ImageDecoderException * @throws DriverException */ public function decodeStream(mixed $stream): ImageInterface { return $this->decode($stream, StreamImageDecoder::class); } }