ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Filesystem\Util\Convert\ImageConversionOptions Class Reference
+ Collaboration diagram for ILIAS\Filesystem\Util\Convert\ImageConversionOptions:

Public Member Functions

 withThrowOnError (bool $throw_on_error)
 If there is any throwable during convertion, this will be thworn again. More...
 
 withMakeTemporaryFiles (bool $make_temporary_files)
 if passing a stream from memory, make a temporary file for this. More...
 
 withFitIn (int $max_size)
 Fit the image into the given size. More...
 
 withKeepAspectRatio (bool $keep_aspect_ratio)
 Keep the aspect ratio while resizing the image. More...
 
 withCrop (bool $crop)
 Crops the final image if needed. More...
 
 withKeepDimensions (bool $keep)
 No resizing, the original image dimension will be used. More...
 
 withWidth (int $width)
 Resize the image to the given width. More...
 
 withHeight (int $height)
 Resize the image to the given height. More...
 
 withFixedDimensions (int $width, int $height)
 Resizes the Image to a fixed size. More...
 
 withOutputPath (string $output_path)
 
 withBackgroundColor (string $background_color)
 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.

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

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

◆ getBackgroundColor()

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

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

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.

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

157  : ImageConversionOptions
158  {
160 
161  $clone = clone $this;
162  $clone->background_color = $background_color;
163  return $clone;
164  }
+ Here is the call graph for this function:

◆ withCrop()

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

Crops the final image if needed.

Definition at line 94 of file ImageConversionOptions.php.

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

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

◆ withFitIn()

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

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  }

◆ withFixedDimensions()

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

Resizes the Image to a fixed size.

Use withCrop() and withKeepAspectRatio() if needed.

Definition at line 137 of file ImageConversionOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\withHeight().

137  : ImageConversionOptions
138  {
139  return $this->withHeight($height)->withWidth($width);
140  }
withHeight(int $height)
Resize the image to the given height.
+ Here is the call graph for this function:

◆ withHeight()

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

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.

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$height, and null.

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

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ withKeepAspectRatio()

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

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.

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

Referenced by ILIAS\Filesystem\Util\Convert\Images\convertToFormat().

84  : ImageConversionOptions
85  {
86  $clone = clone $this;
87  $clone->keep_aspect_ratio = $keep_aspect_ratio;
88  return $clone;
89  }
+ Here is the caller graph for this function:

◆ withKeepDimensions()

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

No resizing, the original image dimension will be used.

Definition at line 104 of file ImageConversionOptions.php.

References null.

Referenced by ILIAS\Filesystem\Util\Convert\Images\convertToFormat().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ withMakeTemporaryFiles()

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

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.

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

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

◆ withOutputPath()

ILIAS\Filesystem\Util\Convert\ImageConversionOptions::withOutputPath ( string  $output_path)
Deprecated:
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.

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

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

◆ withThrowOnError()

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

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.

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

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

◆ withWidth()

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

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.

References ILIAS\Filesystem\Util\Convert\ImageConversionOptions\$width, and null.

Referenced by ILIAS\Filesystem\Util\Convert\Images\convertToFormat().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

Field Documentation

◆ $background_color

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

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

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

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