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

Public Member Functions

 withFormat (string $format)
 set the desired output format. More...
 
 withJpgOutput ()
 set the output format to JPG More...
 
 withPngOutput ()
 set the output format to PNG More...
 
 withWebPOutput ()
 set the output format to WEBP More...
 
 withQuality (int $image_quality)
 set the image compression quality. More...
 
 getFormat ()
 
 getQuality ()
 

Data Fields

const FORMAT_JPG = 'jpg'
 
const FORMAT_PNG = 'png'
 
const FORMAT_WEBP = 'webp'
 
const FORMAT_KEEP = 'keep'
 

Protected Member Functions

 checkImageQuality (int $image_quality)
 

Private Member Functions

 checkFormat (string $format)
 

Private Attributes

int $quality = 75
 
string $format = self::FORMAT_JPG
 
array $allowed_formats
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 26 of file ImageOutputOptions.php.

Member Function Documentation

◆ checkFormat()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::checkFormat ( string  $format)
private

Definition at line 101 of file ImageOutputOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageOutputOptions\$format.

Referenced by ILIAS\Filesystem\Util\Convert\ImageOutputOptions\withFormat().

101  : string
102  {
103  $format = strtolower($format);
104  if ($format === 'jpeg') {
105  $format = self::FORMAT_JPG;
106  }
107 
108  if (!in_array($format, $this->allowed_formats, true)) {
109  throw new \InvalidArgumentException('Format must be either jpg or png, ' . $format . ' given.');
110  }
111  return $format;
112  }
+ Here is the caller graph for this function:

◆ checkImageQuality()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::checkImageQuality ( int  $image_quality)
protected

Definition at line 114 of file ImageOutputOptions.php.

Referenced by ILIAS\Filesystem\Util\Convert\ImageOutputOptions\withQuality().

114  : void
115  {
116  if ($this->format === self::FORMAT_WEBP) {
117  if ($image_quality !== 0 && $image_quality !== 100) {
118  throw new \InvalidArgumentException('WebP only supports quality 0 (loss) or 100 (losless)');
119  }
120  } elseif ($image_quality < 0 || $image_quality > 100) {
121  throw new \InvalidArgumentException('Quality must be between 0 and 100');
122  }
123  }
+ Here is the caller graph for this function:

◆ getFormat()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::getFormat ( )

Definition at line 91 of file ImageOutputOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageOutputOptions\$format.

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

91  : string
92  {
93  return $this->format;
94  }
+ Here is the caller graph for this function:

◆ getQuality()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::getQuality ( )

Definition at line 96 of file ImageOutputOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageOutputOptions\$quality.

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

96  : int
97  {
98  return $this->quality;
99  }
+ Here is the caller graph for this function:

◆ withFormat()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::withFormat ( string  $format)

set the desired output format.

Exceptions

Definition at line 45 of file ImageOutputOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageOutputOptions\$format, and ILIAS\Filesystem\Util\Convert\ImageOutputOptions\checkFormat().

Referenced by ILIAS\Filesystem\Util\Convert\ImageOutputOptions\withJpgOutput(), ILIAS\Filesystem\Util\Convert\ImageOutputOptions\withPngOutput(), and ILIAS\Filesystem\Util\Convert\ImageOutputOptions\withWebPOutput().

45  : ImageOutputOptions
46  {
47  $format = $this->checkFormat($format);
48  $clone = clone $this;
49  $clone->format = $format;
50  return $clone;
51  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withJpgOutput()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::withJpgOutput ( )

set the output format to JPG

Definition at line 56 of file ImageOutputOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageOutputOptions\withFormat().

56  : ImageOutputOptions
57  {
58  return $this->withFormat(self::FORMAT_JPG);
59  }
withFormat(string $format)
set the desired output format.
+ Here is the call graph for this function:

◆ withPngOutput()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::withPngOutput ( )

set the output format to PNG

Definition at line 64 of file ImageOutputOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageOutputOptions\withFormat().

64  : ImageOutputOptions
65  {
66  return $this->withFormat(self::FORMAT_PNG);
67  }
withFormat(string $format)
set the desired output format.
+ Here is the call graph for this function:

◆ withQuality()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::withQuality ( int  $image_quality)

set the image compression quality.

Depending on the format, this will be ignored or other values are needed. JPG: 0-100 WEBP: 0 (loss) or 100 (lossless) PNG: 0-100 (which will be converted to 0-9 internally)

Definition at line 83 of file ImageOutputOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageOutputOptions\checkImageQuality().

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

83  : ImageOutputOptions
84  {
85  $this->checkImageQuality($image_quality);
86  $clone = clone $this;
87  $clone->quality = $image_quality;
88  return $clone;
89  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withWebPOutput()

ILIAS\Filesystem\Util\Convert\ImageOutputOptions::withWebPOutput ( )

set the output format to WEBP

Definition at line 72 of file ImageOutputOptions.php.

References ILIAS\Filesystem\Util\Convert\ImageOutputOptions\withFormat().

72  : ImageOutputOptions
73  {
74  return $this->withFormat(self::FORMAT_WEBP);
75  }
withFormat(string $format)
set the desired output format.
+ Here is the call graph for this function:

Field Documentation

◆ $allowed_formats

array ILIAS\Filesystem\Util\Convert\ImageOutputOptions::$allowed_formats
private
Initial value:
= [
self::FORMAT_JPG,
self::FORMAT_PNG,
self::FORMAT_WEBP,
self::FORMAT_KEEP,
]

Definition at line 34 of file ImageOutputOptions.php.

◆ $format

string ILIAS\Filesystem\Util\Convert\ImageOutputOptions::$format = self::FORMAT_JPG
private

◆ $quality

int ILIAS\Filesystem\Util\Convert\ImageOutputOptions::$quality = 75
private

◆ FORMAT_JPG

const ILIAS\Filesystem\Util\Convert\ImageOutputOptions::FORMAT_JPG = 'jpg'

◆ FORMAT_KEEP

const ILIAS\Filesystem\Util\Convert\ImageOutputOptions::FORMAT_KEEP = 'keep'

◆ FORMAT_PNG

◆ FORMAT_WEBP

const ILIAS\Filesystem\Util\Convert\ImageOutputOptions::FORMAT_WEBP = 'webp'

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