19declare(strict_types=1);
25use ILIAS\ResourceStorage\Flavour\Engine\PHPMemoryLimit;
38 protected function to(\GdImage $image, ?
int $quality =
null):
FileStream
41 imagejpeg($image,
null, $quality ?? 75);
42 $stringdata = ob_get_contents();
51 if ($stream->getSize() > $this->getSizeLimitInBytes()) {
61 return match ($mime) {
62 'image/jpeg' => imagecreatefromjpeg(
$filename),
63 'image/png' => imagecreatefrompng(
$filename),
64 'image/gif' => imagecreatefromgif(
$filename),
65 'image/bmp' => imagecreatefrombmp(
$filename),
66 'image/webp' => imagecreatefromwebp(
$filename),
67 default => imagecreatefromstring((
string) $stream)
69 }
catch (\Throwable) {
Stream factory which enables the user to create streams without the knowledge of the concrete class.
static ofString(string $string)
Creates a new stream with an initial value.
The base interface for all filesystem streams.
to(\GdImage $image, ?int $quality=null)
Currently this is the only way to make a FileStream from a GD image resource.
trait GdImageToStreamTrait