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

Public Member Functions

 withThrowOnError (bool $throw_on_error)
 @description If there is any throwable during convertion, this will be thworn again. More...
 
 withMakeTemporaryFiles (bool $make_temporary_files)
 @description if passing a stream from memory, make a temporary file for this. More...
 
 withFitIn (int $max_size)
 @description Fit the image into the given size. More...
 
 withKeepAspectRatio (bool $keep_aspect_ratio)
 @description Keep the aspect ratio while resizing the image. More...
 
 withCrop (bool $crop)
 @description Crops the final image if needed. More...
 
 withKeepDimensions (bool $keep)
 @description No resizing, the original image dimension will be used. More...
 
 withWidth (int $width)
 @description Resize the image to the given width. More...
 
 withHeight (int $height)
 @description Resize the image to the given height. More...
 
 withFixedDimensions (int $width, int $height)
 @description Resizes the Image to a fixed size. More...
 
 withOutputPath (string $output_path)
 
 withBackgroundColor (string $background_color)
 @description Set a background color for the image. More...
 
 getBackgroundColor ()
 
 getOutputPath ()
 
 getDimensionMode ()
 
 getHeight ()
 
 getWidth ()
 
 keepAspectRatio ()
 
 hasCrop ()
 
 throwOnError ()
 
 makeTemporaryFiles ()
 

Data Fields

const DIMENSION_MODE_NONE = 0
 
const DIMENSION_MODE_FIT = 1
 
const DIMENSTION_MODE_RESIZE_TO_FIXED = 2
 
const DIMENSTION_MODE_RESIZE_BY_HEIGHT = 3
 
const DIMENSTION_MODE_RESIZE_BY_WIDTH = 4
 
const DIMENSION_MODE_KEEP = 5
 

Protected Member Functions

 checkBackgroundColor (string $background_color)
 

Private Attributes

int $dimension_mode = self::DIMENSION_MODE_NONE
 
int $height = null
 
int $width = null
 
bool $keep_aspect_ratio = true
 
string $background_color = null
 
string $output_path = null
 
bool $crop = true
 
bool $throw_on_error = false
 
bool $make_temporary_files = false
 

Detailed Description

Member Function Documentation

◆ checkBackgroundColor()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::checkBackgroundColor ( string  $background_color)
protected

Definition at line 214 of file ImageConversionOptions.php.

214 : void
215 {
216 if (!preg_match('/^#?([a-f0-9]{6})$/i', $background_color)) {
217 throw new \InvalidArgumentException('Invalid background color');
218 }
219 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$background_color.

Referenced by ILIAS\Filesystem\Util\Convert\ImageConversionOptions\withBackgroundColor().

+ Here is the caller graph for this function:

◆ getBackgroundColor()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::getBackgroundColor ( )

Definition at line 166 of file ImageConversionOptions.php.

166 : ?string
167 {
169 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$background_color.

◆ getDimensionMode()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::getDimensionMode ( )

◆ getHeight()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::getHeight ( )

◆ getOutputPath()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::getOutputPath ( )

◆ getWidth()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::getWidth ( )

◆ hasCrop()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::hasCrop ( )

◆ keepAspectRatio()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::keepAspectRatio ( )

◆ makeTemporaryFiles()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::makeTemporaryFiles ( )

◆ throwOnError()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::throwOnError ( )

◆ withBackgroundColor()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withBackgroundColor ( string  $background_color)

@description Set a background color for the image.

This is used e.g. while converting transparent pngs to jpgs.

Definition at line 157 of file ImageConversionOptions.php.

157 : ImageConversionOptions
158 {
160
161 $clone = clone $this;
162 $clone->background_color = $background_color;
163 return $clone;
164 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$background_color, and ILIAS\Filesystem\Util\Convert\ImageConversionOptions\checkBackgroundColor().

+ Here is the call graph for this function:

◆ withCrop()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withCrop ( bool  $crop)

@description Crops the final image if needed.

Definition at line 94 of file ImageConversionOptions.php.

94 : ImageConversionOptions
95 {
96 $clone = clone $this;
97 $clone->crop = $crop;
98 return $clone;
99 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$crop.

◆ withFitIn()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withFitIn ( int  $max_size)

@description Fit the image into the given size.

Depending on the withCrop option, the image will be cropped or not.

Definition at line 73 of file ImageConversionOptions.php.

73 : ImageConversionOptions
74 {
75 $clone = clone $this;
76 $clone->dimension_mode = self::DIMENSION_MODE_FIT;
77 $clone->width = $clone->height = $max_size;
78 return $clone;
79 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\DIMENSION_MODE_FIT.

◆ withFixedDimensions()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withFixedDimensions ( int  $width,
int  $height 
)

@description Resizes the Image to a fixed size.

Use withCrop() and withKeepAspectRatio() if needed.

Definition at line 137 of file ImageConversionOptions.php.

137 : ImageConversionOptions
138 {
139 return $this->withHeight($height)->withWidth($width);
140 }
withHeight(int $height)
@description Resize the image to the given height.

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$width, and ILIAS\Filesystem\Util\Convert\ImageConversionOptions\withHeight().

+ Here is the call graph for this function:

◆ withHeight()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withHeight ( int  $height)

@description Resize the image to the given height.

Depends on withWidth() if the image will be resized to a fixed size or depending on the height.

Definition at line 126 of file ImageConversionOptions.php.

126 : ImageConversionOptions
127 {
128 $clone = clone $this;
129 $clone->dimension_mode = ($this->width === null) ? self::DIMENSTION_MODE_RESIZE_BY_HEIGHT : self::DIMENSTION_MODE_RESIZE_TO_FIXED;
130 $clone->height = $height;
131 return $clone;
132 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$height.

Referenced by ILIAS\Filesystem\Util\Convert\Images\convertToFormat(), and ILIAS\Filesystem\Util\Convert\ImageConversionOptions\withFixedDimensions().

+ Here is the caller graph for this function:

◆ withKeepAspectRatio()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withKeepAspectRatio ( bool  $keep_aspect_ratio)

@description Keep the aspect ratio while resizing the image.

If used with withCrop, the image will be cropped as well to fit the size.

Definition at line 84 of file ImageConversionOptions.php.

84 : ImageConversionOptions
85 {
86 $clone = clone $this;
87 $clone->keep_aspect_ratio = $keep_aspect_ratio;
88 return $clone;
89 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$keep_aspect_ratio.

◆ withKeepDimensions()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withKeepDimensions ( bool  $keep)

@description No resizing, the original image dimension will be used.

Definition at line 104 of file ImageConversionOptions.php.

104 : ImageConversionOptions
105 {
106 $clone = clone $this;
107 $clone->dimension_mode = self::DIMENSION_MODE_KEEP;
108 $this->width = $this->height = null;
109 return $clone;
110 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\DIMENSION_MODE_KEEP.

◆ withMakeTemporaryFiles()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withMakeTemporaryFiles ( bool  $make_temporary_files)

@description if passing a stream from memory, make a temporary file for this.

otherwise, the php://memory stream will be used which can cause problems with imagick in some circumstances, but is faster.

Definition at line 63 of file ImageConversionOptions.php.

63 : self
64 {
65 $clone = clone $this;
66 $clone->make_temporary_files = $make_temporary_files;
67 return $clone;
68 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$make_temporary_files.

◆ withOutputPath()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withOutputPath ( string  $output_path)
Deprecated:
@description Set an write path for the converted image. If not set, the image will be converted in memory.

Definition at line 146 of file ImageConversionOptions.php.

146 : ImageConversionOptions
147 {
148 $clone = clone $this;
149 $clone->output_path = $output_path;
150 return $clone;
151 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$output_path.

◆ withThrowOnError()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withThrowOnError ( bool  $throw_on_error)

@description If there is any throwable during convertion, this will be thworn again.

otherwise one must check with isOK()

Definition at line 50 of file ImageConversionOptions.php.

50 : self
51 {
52 $clone = clone $this;
53 $clone->throw_on_error = $throw_on_error;
54 return $clone;
55 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$throw_on_error.

◆ withWidth()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withWidth ( int  $width)

@description Resize the image to the given width.

Depends on withHeight() if the image will be resized to a fixed size or depending on the width.

Definition at line 115 of file ImageConversionOptions.php.

115 : ImageConversionOptions
116 {
117 $clone = clone $this;
118 $clone->dimension_mode = ($this->height === null) ? self::DIMENSTION_MODE_RESIZE_BY_WIDTH : self::DIMENSTION_MODE_RESIZE_TO_FIXED;
119 $clone->width = $width;
120 return $clone;
121 }

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$width.

Field Documentation

◆ $background_color

◆ $crop

bool ILIAS\Filesystem\Util\Convert\ImageConversionOptions::$crop = true
private

◆ $dimension_mode

int ILIAS\Filesystem\Util\Convert\ImageConversionOptions::$dimension_mode = self::DIMENSION_MODE_NONE
private

◆ $height

int ILIAS\Filesystem\Util\Convert\ImageConversionOptions::$height = null
private

◆ $keep_aspect_ratio

bool ILIAS\Filesystem\Util\Convert\ImageConversionOptions::$keep_aspect_ratio = true
private

◆ $make_temporary_files

bool ILIAS\Filesystem\Util\Convert\ImageConversionOptions::$make_temporary_files = false
private

◆ $output_path

string ILIAS\Filesystem\Util\Convert\ImageConversionOptions::$output_path = null
private

◆ $throw_on_error

bool ILIAS\Filesystem\Util\Convert\ImageConversionOptions::$throw_on_error = false
private

◆ $width

◆ DIMENSION_MODE_FIT

const ILIAS\Filesystem\Util\Convert\ImageConversionOptions::DIMENSION_MODE_FIT = 1

◆ DIMENSION_MODE_KEEP

const ILIAS\Filesystem\Util\Convert\ImageConversionOptions::DIMENSION_MODE_KEEP = 5

◆ DIMENSION_MODE_NONE

const ILIAS\Filesystem\Util\Convert\ImageConversionOptions::DIMENSION_MODE_NONE = 0

◆ DIMENSTION_MODE_RESIZE_BY_HEIGHT

const ILIAS\Filesystem\Util\Convert\ImageConversionOptions::DIMENSTION_MODE_RESIZE_BY_HEIGHT = 3

◆ DIMENSTION_MODE_RESIZE_BY_WIDTH

const ILIAS\Filesystem\Util\Convert\ImageConversionOptions::DIMENSTION_MODE_RESIZE_BY_WIDTH = 4

◆ DIMENSTION_MODE_RESIZE_TO_FIXED

const ILIAS\Filesystem\Util\Convert\ImageConversionOptions::DIMENSTION_MODE_RESIZE_TO_FIXED = 2

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