ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Filesystem\Util\Convert\LegacyImages Class Reference
+ Collaboration diagram for ILIAS\Filesystem\Util\Convert\LegacyImages:

Public Member Functions

 __construct ()
 
 thumbnail (string $path_to_original, string $path_to_output, int $fit_into_size, string $output_format=ImageOutputOptions::FORMAT_KEEP, int $image_quality=75)
 
 croppedSquare (string $path_to_original, string $path_to_output, int $square_size, string $output_format=ImageOutputOptions::FORMAT_KEEP, int $image_quality=75)
 
 resizeByWidth (string $path_to_original, string $path_to_output, int $width, string $output_format=ImageOutputOptions::FORMAT_KEEP, int $image_quality=60)
 
 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)
 
 convertToFormat (string $path_to_original, string $path_to_output, string $output_format, ?int $width=null, ?int $height=null)
 

Private Member Functions

 storeStream (ImageConverter $converter, string $path)
 
 buildStream (string $path_to_original)
 

Private Attributes

Images $image_converters
 
ImageOutputOptions $output_options
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s
Deprecated:
ise \ILIAS\Filesystem\Util\Convert\Images instead

Definition at line 31 of file LegacyImages.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Filesystem\Util\Convert\LegacyImages::__construct ( )

Definition at line 36 of file LegacyImages.php.

37 {
38 $this->image_converters = new Images(false);
39 $this->output_options = new ImageOutputOptions();
40 }

Member Function Documentation

◆ buildStream()

ILIAS\Filesystem\Util\Convert\LegacyImages::buildStream ( string  $path_to_original)
private

Definition at line 196 of file LegacyImages.php.

196 : Stream|FileStream
197 {
198 return Streams::ofResource(fopen($path_to_original, 'rb'));
199 }
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:64

◆ convertToFormat()

ILIAS\Filesystem\Util\Convert\LegacyImages::convertToFormat ( string  $path_to_original,
string  $path_to_output,
string  $output_format,
?int  $width = null,
?int  $height = null 
)

Definition at line 165 of file LegacyImages.php.

171 : string {
172 $converter = $this->image_converters->convertToFormat(
173 $this->buildStream($path_to_original),
174 $output_format,
175 $width,
176 $height
177 );
178 return $this->storeStream($converter, $path_to_output);
179 }
storeStream(ImageConverter $converter, string $path)

◆ croppedSquare()

ILIAS\Filesystem\Util\Convert\LegacyImages::croppedSquare ( string  $path_to_original,
string  $path_to_output,
int  $square_size,
string  $output_format = ImageOutputOptions::FORMAT_KEEP,
int  $image_quality = 75 
)
Returns
string path to the thumbnail
Deprecated:
Use \ILIAS\Filesystem\Util\Convert\Images::croppedSquare() instead.

Definition at line 74 of file LegacyImages.php.

80 : string {
81 $converter = $this->image_converters->croppedSquare(
82 $this->buildStream($path_to_original),
83 $square_size,
84 $this->output_options
85 ->withQuality($image_quality)
86 ->withFormat($output_format)
87 );
88
89 return $this->storeStream($converter, $path_to_output);
90 }

◆ resizeByHeight()

ILIAS\Filesystem\Util\Convert\LegacyImages::resizeByHeight ( string  $path_to_original,
string  $path_to_output,
int  $height,
string  $output_format = ImageOutputOptions::FORMAT_KEEP,
int  $image_quality = 60 
)
Deprecated:
Use \ILIAS\Filesystem\Util\Convert\Images::resizeByHeight() instead.
Returns
string path to the resized image

Definition at line 122 of file LegacyImages.php.

128 : string {
129 $converter = $this->image_converters->resizeByHeight(
130 $this->buildStream($path_to_original),
131 $height,
132 $this->output_options
133 ->withQuality($image_quality)
134 ->withFormat($output_format)
135 );
136 return $this->storeStream($converter, $path_to_output);
137 }

◆ resizeByWidth()

ILIAS\Filesystem\Util\Convert\LegacyImages::resizeByWidth ( string  $path_to_original,
string  $path_to_output,
int  $width,
string  $output_format = ImageOutputOptions::FORMAT_KEEP,
int  $image_quality = 60 
)
Returns
string path to the thumbnail
Deprecated:
Use \ILIAS\Filesystem\Util\Convert\Images::resizeByWidth() instead.

Definition at line 100 of file LegacyImages.php.

106 : string {
107 $converter = $this->image_converters->resizeByWidth(
108 $this->buildStream($path_to_original),
109 $width,
110 $this->output_options
111 ->withQuality($image_quality)
112 ->withFormat($output_format)
113 );
114 return $this->storeStream($converter, $path_to_output);
115 }

◆ resizeToFixedSize()

ILIAS\Filesystem\Util\Convert\LegacyImages::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 
)
Returns
string path to the thumbnail
Deprecated:
Use \ILIAS\Filesystem\Util\Convert\Images::resizeToFixedSize() instead.

Definition at line 144 of file LegacyImages.php.

152 : string {
153 $converter = $this->image_converters->resizeToFixedSize(
154 $this->buildStream($path_to_original),
155 $width,
156 $height,
157 $crop_if_true_and_resize_if_false,
158 $this->output_options
159 ->withQuality($image_quality)
160 ->withFormat($output_format)
161 );
162 return $this->storeStream($converter, $path_to_output);
163 }

◆ storeStream()

ILIAS\Filesystem\Util\Convert\LegacyImages::storeStream ( ImageConverter  $converter,
string  $path 
)
private

Definition at line 181 of file LegacyImages.php.

181 : string
182 {
183 if (!$converter->isOK()) {
184 throw $converter->getThrowableIfAny() ?? new \RuntimeException('Could not create requested image');
185 }
186
187 $stream = $converter->getStream();
188
189 $stream->rewind();
190 if (file_put_contents($path, $stream->getContents()) === false) {
191 throw new \RuntimeException('Could not store image');
192 }
193 return $path;
194 }
$path
Definition: ltiservices.php:30

References $path, ILIAS\Filesystem\Util\Convert\ImageConverter\getStream(), ILIAS\Filesystem\Util\Convert\ImageConverter\getThrowableIfAny(), and ILIAS\Filesystem\Util\Convert\ImageConverter\isOK().

+ Here is the call graph for this function:

◆ thumbnail()

ILIAS\Filesystem\Util\Convert\LegacyImages::thumbnail ( string  $path_to_original,
string  $path_to_output,
int  $fit_into_size,
string  $output_format = ImageOutputOptions::FORMAT_KEEP,
int  $image_quality = 75 
)
Returns
string path to the thumbnail
Deprecated:
Use \ILIAS\Filesystem\Util\Convert\Images::thumbnail() instead.

Definition at line 49 of file LegacyImages.php.

55 : string {
56 $converter = $this->image_converters->thumbnail(
57 $this->buildStream($path_to_original),
58 $fit_into_size,
59 $this->output_options
60 ->withQuality($image_quality)
61 ->withFormat($output_format)
62 );
63 return $this->storeStream($converter, $path_to_output);
64 }

Field Documentation

◆ $image_converters

Images ILIAS\Filesystem\Util\Convert\LegacyImages::$image_converters
private

Definition at line 33 of file LegacyImages.php.

◆ $output_options

ImageOutputOptions ILIAS\Filesystem\Util\Convert\LegacyImages::$output_options
private

Definition at line 34 of file LegacyImages.php.


The documentation for this class was generated from the following file: