Loheide-eu-mitarbeiterplatt.../vendor/intervention/image/src/ImageManager.php
Friederich Loheide 9c0f8de791
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Phase 0: Fundament für Inhaus
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3)
- Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung
- Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü
- Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person
- Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“
- Benutzerverwaltung im Admin, Zugang vorläufig über is_admin
- vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/
- PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung
- VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 20:35:30 +00:00

180 lines
5 KiB
PHP

<?php
declare(strict_types=1);
namespace Intervention\Image;
use Intervention\Image\Decoders\Base64ImageDecoder;
use Intervention\Image\Decoders\BinaryImageDecoder;
use Intervention\Image\Decoders\DataUriImageDecoder;
use Intervention\Image\Decoders\FilePathImageDecoder;
use Intervention\Image\Decoders\StreamImageDecoder;
use Intervention\Image\Decoders\SplFileInfoImageDecoder;
use Intervention\Image\Exceptions\DriverException;
use Intervention\Image\Exceptions\ImageDecoderException;
use Intervention\Image\Exceptions\InvalidArgumentException;
use Intervention\Image\Interfaces\AnimationFactoryInterface;
use Intervention\Image\Interfaces\DataUriInterface;
use Intervention\Image\Interfaces\DecoderInterface;
use Intervention\Image\Interfaces\DriverInterface;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ImageManagerInterface;
use Intervention\Image\Traits\CanResolveDriver;
use SplFileInfo;
use Stringable;
class ImageManager implements ImageManagerInterface
{
use CanResolveDriver;
public DriverInterface $driver;
/**
* Create new image manager instance.
*
* @link https://image.intervention.io/v4/basics/configuration-drivers#create-a-new-image-manager-instance
*
* @throws InvalidArgumentException
*/
public function __construct(string|DriverInterface $driver, mixed ...$options)
{
$this->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);
}
}