19 declare(strict_types=1);
38 $this->image_converters =
new Images(
false);
50 string $path_to_original,
51 string $path_to_output,
54 int $image_quality = 75
56 $converter = $this->image_converters->thumbnail(
60 ->withQuality($image_quality)
61 ->withFormat($output_format)
63 return $this->
storeStream($converter, $path_to_output);
75 string $path_to_original,
76 string $path_to_output,
79 int $image_quality = 75
81 $converter = $this->image_converters->croppedSquare(
85 ->withQuality($image_quality)
86 ->withFormat($output_format)
89 return $this->
storeStream($converter, $path_to_output);
101 string $path_to_original,
102 string $path_to_output,
105 int $image_quality = 60
107 $converter = $this->image_converters->resizeByWidth(
110 $this->output_options
111 ->withQuality($image_quality)
112 ->withFormat($output_format)
114 return $this->
storeStream($converter, $path_to_output);
123 string $path_to_original,
124 string $path_to_output,
127 int $image_quality = 60
129 $converter = $this->image_converters->resizeByHeight(
132 $this->output_options
133 ->withQuality($image_quality)
134 ->withFormat($output_format)
136 return $this->
storeStream($converter, $path_to_output);
145 string $path_to_original,
146 string $path_to_output,
149 bool $crop_if_true_and_resize_if_false =
true,
151 int $image_quality = 60
153 $converter = $this->image_converters->resizeToFixedSize(
157 $crop_if_true_and_resize_if_false,
158 $this->output_options
159 ->withQuality($image_quality)
160 ->withFormat($output_format)
162 return $this->
storeStream($converter, $path_to_output);
166 string $path_to_original,
167 string $path_to_output,
168 string $output_format,
172 $converter = $this->image_converters->convertToFormat(
178 return $this->
storeStream($converter, $path_to_output);
183 if (!$converter->
isOK()) {
184 throw $converter->
getThrowableIfAny() ?? new \RuntimeException(
'Could not create requested image');
190 if (file_put_contents($path, $stream->getContents()) ===
false) {
191 throw new \RuntimeException(
'Could not store image');
198 return Streams::ofResource(fopen($path_to_original,
'rb'));
ImageOutputOptions $output_options
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
buildStream(string $path_to_original)
convertToFormat(string $path_to_original, string $path_to_output, string $output_format, ?int $width=null, ?int $height=null)
croppedSquare(string $path_to_original, string $path_to_output, int $square_size, string $output_format=ImageOutputOptions::FORMAT_KEEP, int $image_quality=75)
storeStream(ImageConverter $converter, string $path)
resizeByHeight(string $path_to_original, string $path_to_output, int $height, string $output_format=ImageOutputOptions::FORMAT_KEEP, int $image_quality=60)
resizeToFixedSize(string $path_to_original, string $path_to_output, int $width, int $height, bool $crop_if_true_and_resize_if_false=true, string $output_format=ImageOutputOptions::FORMAT_KEEP, int $image_quality=60)
The base interface for all filesystem streams.
resizeByWidth(string $path_to_original, string $path_to_output, int $width, string $output_format=ImageOutputOptions::FORMAT_KEEP, int $image_quality=60)
thumbnail(string $path_to_original, string $path_to_output, int $fit_into_size, string $output_format=ImageOutputOptions::FORMAT_KEEP, int $image_quality=75)