ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
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 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

◆ 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.

References ILIAS\Filesystem\Util\Convert\LegacyImages\buildStream(), and ILIAS\Filesystem\Util\Convert\LegacyImages\storeStream().

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)
+ Here is the call graph for this function:

◆ 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 ::croppedSquare() instead.

Definition at line 74 of file LegacyImages.php.

References ILIAS\Filesystem\Util\Convert\LegacyImages\buildStream(), and ILIAS\Filesystem\Util\Convert\LegacyImages\storeStream().

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  }
storeStream(ImageConverter $converter, string $path)
+ Here is the call graph for this function:

◆ 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 ::resizeByHeight() instead.
Returns
string path to the resized image

Definition at line 122 of file LegacyImages.php.

References ILIAS\Filesystem\Util\Convert\LegacyImages\buildStream(), and ILIAS\Filesystem\Util\Convert\LegacyImages\storeStream().

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  }
storeStream(ImageConverter $converter, string $path)
+ Here is the call graph for this function:

◆ 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 ::resizeByWidth() instead.

Definition at line 100 of file LegacyImages.php.

References ILIAS\Filesystem\Util\Convert\LegacyImages\buildStream(), and ILIAS\Filesystem\Util\Convert\LegacyImages\storeStream().

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  }
storeStream(ImageConverter $converter, string $path)
+ Here is the call graph for this function:

◆ 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 ::resizeToFixedSize() instead.

Definition at line 144 of file LegacyImages.php.

References ILIAS\Filesystem\Util\Convert\LegacyImages\buildStream(), and ILIAS\Filesystem\Util\Convert\LegacyImages\storeStream().

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(ImageConverter $converter, string $path)
+ Here is the call graph for this function:

◆ storeStream()

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

Definition at line 181 of file LegacyImages.php.

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

Referenced by ILIAS\Filesystem\Util\Convert\LegacyImages\convertToFormat(), ILIAS\Filesystem\Util\Convert\LegacyImages\croppedSquare(), ILIAS\Filesystem\Util\Convert\LegacyImages\resizeByHeight(), ILIAS\Filesystem\Util\Convert\LegacyImages\resizeByWidth(), ILIAS\Filesystem\Util\Convert\LegacyImages\resizeToFixedSize(), and ILIAS\Filesystem\Util\Convert\LegacyImages\thumbnail().

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:29
+ Here is the call graph for this function:
+ Here is the caller 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 ::thumbnail() instead.

Definition at line 49 of file LegacyImages.php.

References ILIAS\Filesystem\Util\Convert\LegacyImages\buildStream(), and ILIAS\Filesystem\Util\Convert\LegacyImages\storeStream().

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  }
storeStream(ImageConverter $converter, string $path)
+ Here is the call graph for this function:

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: