ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Filesystem\Util\ImageConversionTest Class Reference
+ Inheritance diagram for ILIAS\Filesystem\Util\ImageConversionTest:
+ Collaboration diagram for ILIAS\Filesystem\Util\ImageConversionTest:

Public Member Functions

 testImageThumbnailActualImage ()
 
 testImageSquareActualImage ()
 
 testResizeToFitWidth (int $width, int $height, int $final_width, int $final_height)
 
 testResizeToFitHeight (int $width, int $height, int $final_height, int $final_width)
 
 testResizeByFixedSize (int $width, int $height, int $final_width, int $final_height, bool $crop)
 
 testImageOutputOptions (ImageOutputOptions $options, string $expected_mime_type, int $expected_quality)
 
 testImageOutputOptionSanity ()
 
 testWrongFormats (string $format)
 
 testWrongQualities (int $quality)
 
 testFormatConvert ()
 
 testFailed ()
 
 testBackgroundColor (?string $color)
 
 testWriteImage ()
 
 testHighDensityPixel ()
 

Static Public Member Functions

static getImageSizesByWidth ()
 
static getImageSizesByHeight ()
 
static getImageSizesByFixed ()
 
static getImageOptions ()
 
static getWrongFormats ()
 
static getWrongQualites ()
 
static getColors ()
 

Protected Member Functions

 setUp ()
 
 checkImagick ()
 
 getImageSizeFromStream (FileStream $stream)
 
 getImageTypeFromStream (FileStream $stream)
 
 getImageQualityFromStream (FileStream $stream)
 
 createTestImageStream (int $width, int $height)
 

Protected Attributes

const BY_WIDTH_FINAL = 256
 
const BY_HEIGHT_FINAL = 756
 
const W = 'width'
 
const H = 'height'
 
const IMAGE_JPEG = 'image/jpeg'
 
const IMAGE_PNG = 'image/png'
 
const IMAGE_WEBP = 'image/webp'
 
Images $images
 

Private Member Functions

 colorDiff (string $hex_color_one, string $hex_color_two)
 

Detailed Description

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

Definition at line 33 of file ImageConversionTest.php.

Member Function Documentation

◆ checkImagick()

ILIAS\Filesystem\Util\ImageConversionTest::checkImagick ( )
protected

Definition at line 496 of file ImageConversionTest.php.

Referenced by ILIAS\Filesystem\Util\ImageConversionTest\setUp().

496  : void
497  {
498  if (!class_exists('Imagick')) {
499  $this->markTestSkipped('Imagick not installed');
500  }
501  }
+ Here is the caller graph for this function:

◆ colorDiff()

ILIAS\Filesystem\Util\ImageConversionTest::colorDiff ( string  $hex_color_one,
string  $hex_color_two 
)
private

Definition at line 399 of file ImageConversionTest.php.

Referenced by ILIAS\Filesystem\Util\ImageConversionTest\testBackgroundColor().

399  : int
400  {
401  preg_match('/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i', $hex_color_one, $rgb_one);
402  preg_match('/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i', $hex_color_two, $rgb_two);
403 
404  return abs(hexdec($rgb_one[1]) - hexdec($rgb_two[1]))
405  + abs(hexdec($rgb_one[2]) - hexdec($rgb_two[2]))
406  + abs(hexdec($rgb_one[3]) - hexdec($rgb_two[3]));
407  }
+ Here is the caller graph for this function:

◆ createTestImageStream()

ILIAS\Filesystem\Util\ImageConversionTest::createTestImageStream ( int  $width,
int  $height 
)
protected

Definition at line 526 of file ImageConversionTest.php.

Referenced by ILIAS\Filesystem\Util\ImageConversionTest\testFormatConvert(), ILIAS\Filesystem\Util\ImageConversionTest\testImageOutputOptions(), ILIAS\Filesystem\Util\ImageConversionTest\testResizeByFixedSize(), ILIAS\Filesystem\Util\ImageConversionTest\testResizeToFitHeight(), ILIAS\Filesystem\Util\ImageConversionTest\testResizeToFitWidth(), and ILIAS\Filesystem\Util\ImageConversionTest\testWriteImage().

526  : FileStream
527  {
528  $img = new \Imagick();
529  $img->newImage($width, $height, new \ImagickPixel('black'));
530  $img->setImageFormat('jpg');
531 
532  $stream = Streams::ofString($img->getImageBlob());
533  $stream->rewind();
534  return $stream;
535  }
+ Here is the caller graph for this function:

◆ getColors()

static ILIAS\Filesystem\Util\ImageConversionTest::getColors ( )
static

Definition at line 381 of file ImageConversionTest.php.

References null.

381  : array
382  {
383  return [
384  [null],
385  ['#000000'],
386  ['#ff0000'],
387  ['#00ff00'],
388  ['#0000ff'],
389  ['#ffffff'],
390  ['#A3BF5A'],
391  ['#E9745A'],
392  ['#5A5AE9'],
393  ['#5AE9E9'],
394  ['#E95AE9'],
395  ['#E9E95A'],
396  ];
397  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getImageOptions()

static ILIAS\Filesystem\Util\ImageConversionTest::getImageOptions ( )
static

Definition at line 239 of file ImageConversionTest.php.

239  : array
240  {
241  $options = new ImageOutputOptions();
242  return [
243  [$options, self::IMAGE_JPEG, 75],
244  [$options->withPngOutput()->withQuality(22), self::IMAGE_PNG, 0],
245  [$options->withJpgOutput()->withQuality(100), self::IMAGE_JPEG, 100],
246  [$options->withFormat('png')->withQuality(50), self::IMAGE_PNG, 0],
247  [$options->withFormat('jpg')->withQuality(87), self::IMAGE_JPEG, 87],
248  [$options->withQuality(5)->withJpgOutput(), self::IMAGE_JPEG, 5],
249  [$options->withQuality(10)->withJpgOutput(), self::IMAGE_JPEG, 10],
250  [$options->withQuality(35)->withJpgOutput(), self::IMAGE_JPEG, 35],
251  [$options->withQuality(0)->withWebPOutput(), self::IMAGE_WEBP, 0],
252  [$options->withQuality(100)->withWebPOutput(), self::IMAGE_WEBP, 100],
253  ];
254  }

◆ getImageQualityFromStream()

ILIAS\Filesystem\Util\ImageConversionTest::getImageQualityFromStream ( FileStream  $stream)
protected

Definition at line 517 of file ImageConversionTest.php.

Referenced by ILIAS\Filesystem\Util\ImageConversionTest\testImageOutputOptions().

517  : int
518  {
519  $stream->rewind();
520  $img = new \Imagick();
521  $img->readImageBlob((string) $stream);
522 
523  return $img->getImageCompressionQuality();
524  }
+ Here is the caller graph for this function:

◆ getImageSizeFromStream()

ILIAS\Filesystem\Util\ImageConversionTest::getImageSizeFromStream ( FileStream  $stream)
protected

Definition at line 503 of file ImageConversionTest.php.

References ILIAS\Repository\int().

Referenced by ILIAS\Filesystem\Util\ImageConversionTest\testFormatConvert(), ILIAS\Filesystem\Util\ImageConversionTest\testImageSquareActualImage(), ILIAS\Filesystem\Util\ImageConversionTest\testResizeByFixedSize(), ILIAS\Filesystem\Util\ImageConversionTest\testResizeToFitHeight(), and ILIAS\Filesystem\Util\ImageConversionTest\testResizeToFitWidth().

503  : array
504  {
505  $getimagesizefromstring = getimagesizefromstring((string) $stream);
506  return [
507  self::W => (int) round($getimagesizefromstring[0]),
508  self::H => (int) round($getimagesizefromstring[1])
509  ];
510  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageSizesByFixed()

static ILIAS\Filesystem\Util\ImageConversionTest::getImageSizesByFixed ( )
static

Definition at line 206 of file ImageConversionTest.php.

206  : array
207  {
208  return [
209  [1024, 768, 300, 100, true],
210  [1024, 768, 300, 100, false],
211  [1024, 768, 100, 300, true],
212  [1024, 768, 100, 300, false],
213  [400, 300, 500, 400, true],
214  [400, 300, 500, 400, false],
215  ];
216  }

◆ getImageSizesByHeight()

static ILIAS\Filesystem\Util\ImageConversionTest::getImageSizesByHeight ( )
static

Definition at line 156 of file ImageConversionTest.php.

156  : array
157  {
158  return [
159  [400, 300, self::BY_HEIGHT_FINAL, 1008],
160  [300, 400, self::BY_HEIGHT_FINAL, 567],
161  [200, 200, self::BY_HEIGHT_FINAL, 756],
162  [248, 845, self::BY_HEIGHT_FINAL, 221],
163  ];
164  }

◆ getImageSizesByWidth()

static ILIAS\Filesystem\Util\ImageConversionTest::getImageSizesByWidth ( )
static

Definition at line 107 of file ImageConversionTest.php.

107  : array
108  {
109  return [
110  [400, 300, self::BY_WIDTH_FINAL, 192],
111  [300, 400, self::BY_WIDTH_FINAL, 341],
112  [543, 431, self::BY_WIDTH_FINAL, 203],
113  [200, 200, self::BY_WIDTH_FINAL, 256],
114  ];
115  }

◆ getImageTypeFromStream()

ILIAS\Filesystem\Util\ImageConversionTest::getImageTypeFromStream ( FileStream  $stream)
protected

Definition at line 512 of file ImageConversionTest.php.

Referenced by ILIAS\Filesystem\Util\ImageConversionTest\testFormatConvert(), and ILIAS\Filesystem\Util\ImageConversionTest\testImageOutputOptions().

512  : string
513  {
514  return finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $stream->read(255));
515  }
+ Here is the caller graph for this function:

◆ getWrongFormats()

static ILIAS\Filesystem\Util\ImageConversionTest::getWrongFormats ( )
static

Definition at line 302 of file ImageConversionTest.php.

302  : array
303  {
304  return [
305  ['gif'],
306  ['bmp'],
307  ['jpg2000'],
308  ];
309  }

◆ getWrongQualites()

static ILIAS\Filesystem\Util\ImageConversionTest::getWrongQualites ( )
static

Definition at line 319 of file ImageConversionTest.php.

319  : array
320  {
321  return [
322  [-1],
323  [101],
324  [102],
325  ];
326  }

◆ setUp()

ILIAS\Filesystem\Util\ImageConversionTest::setUp ( )
protected

Definition at line 46 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\checkImagick().

46  : void
47  {
48  $this->checkImagick();
49  $this->images = new Images(
50  true,
51  );
52  }
+ Here is the call graph for this function:

◆ testBackgroundColor()

ILIAS\Filesystem\Util\ImageConversionTest::testBackgroundColor ( ?string  $color)

Definition at line 410 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\colorDiff(), and null.

410  : void
411  {
412  $transparent_png = __DIR__ . '/img/transparent.png';
413  $this->assertFileExists($transparent_png);
414  $png = Streams::ofResource(fopen($transparent_png, 'rb'));
415 
416  $converter_options = (new ImageConversionOptions())
417  ->withThrowOnError(true)
418  ->withFixedDimensions(100, 100);
419 
420  if ($color !== null) {
421  $converter_options = $converter_options->withBackgroundColor($color);
422  } else {
423  $color = '#ffffff';
424  }
425 
426  $output_options = (new ImageOutputOptions())
427  ->withQuality(100)
428  ->withJpgOutput();
429 
430  $converter = new ImageConverter($converter_options, $output_options, $png);
431  $this->assertTrue($converter->isOK());
432  $converted_stream = $converter->getStream();
433  $gd_image = imagecreatefromstring((string) $converted_stream);
434  $colors = imagecolorsforindex($gd_image, imagecolorat($gd_image, 1, 1));
435 
436  $color_in_converted_picture = sprintf("#%02x%02x%02x", $colors['red'], $colors['green'], $colors['blue']);
437  $color_diff = $this->colorDiff($color, $color_in_converted_picture);
438 
439  $this->assertLessThan(3, $color_diff);
440  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
colorDiff(string $hex_color_one, string $hex_color_two)
+ Here is the call graph for this function:

◆ testFailed()

ILIAS\Filesystem\Util\ImageConversionTest::testFailed ( )

Definition at line 364 of file ImageConversionTest.php.

364  : void
365  {
366  $false_stream = Streams::ofString('false');
367  $images = new Images(
368  false,
369  false
370  );
371 
372  $resized = $images->resizeToFixedSize(
373  $false_stream,
374  5,
375  5
376  );
377  $this->assertFalse($resized->isOK());
378  $this->assertInstanceOf(\Throwable::class, $resized->getThrowableIfAny());
379  }

◆ testFormatConvert()

ILIAS\Filesystem\Util\ImageConversionTest::testFormatConvert ( )

Definition at line 336 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\createTestImageStream(), ILIAS\Filesystem\Util\ImageConversionTest\getImageSizeFromStream(), and ILIAS\Filesystem\Util\ImageConversionTest\getImageTypeFromStream().

336  : void
337  {
338  $jpg = $this->createTestImageStream(10, 10);
339  $png = $this->images->convertToFormat(
340  $jpg,
341  'png'
342  );
343 
344  $this->assertEquals(self::IMAGE_PNG, $this->getImageTypeFromStream($png->getStream()));
345  $size = $this->getImageSizeFromStream($png->getStream());
346  $this->assertEquals(10, $size[self::W]);
347  $this->assertEquals(10, $size[self::H]);
348 
349  // With Dimensions
350  $jpg = $this->createTestImageStream(10, 10);
351  $png = $this->images->convertToFormat(
352  $jpg,
353  'png',
354  20,
355  20
356  );
357 
358  $this->assertEquals(self::IMAGE_PNG, $this->getImageTypeFromStream($png->getStream()));
359  $size = $this->getImageSizeFromStream($png->getStream());
360  $this->assertEquals(20, $size[self::W]);
361  $this->assertEquals(20, $size[self::H]);
362  }
+ Here is the call graph for this function:

◆ testHighDensityPixel()

ILIAS\Filesystem\Util\ImageConversionTest::testHighDensityPixel ( )

Definition at line 467 of file ImageConversionTest.php.

467  : void
468  {
469  $file = 'https://upload.wikimedia.org/wikipedia/commons/5/5e/Jan_Vermeer_-_The_Art_of_Painting_-_Google_Art_Project.jpg';
470  $curl = curl_init();
471  curl_setopt($curl, CURLOPT_URL, $file);
472  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
473  curl_setopt($curl, CURLOPT_USERAGENT, 'PHPUnit/1.0');
474  $string = curl_exec($curl);
475  curl_close($curl);
476 
477  $img = Streams::ofString($string);
478  $this->assertInstanceOf(FileStream::class, $img);
479 
480  $converter_options = (new ImageConversionOptions())
481  ->withWidth(80)
482  ->withHeight(80)
483  ->withKeepAspectRatio(true)
484  ->withCrop(true)
485  ->withThrowOnError(true);
486 
487  $output_options = (new ImageOutputOptions())
488  ->withQuality(60)
489  ->withFormat(ImageOutputOptions::FORMAT_PNG);
490 
491  $converter = new ImageConverter($converter_options, $output_options, $img);
492  $this->assertTrue($converter->isOK());
493  }

◆ testImageOutputOptions()

ILIAS\Filesystem\Util\ImageConversionTest::testImageOutputOptions ( ImageOutputOptions  $options,
string  $expected_mime_type,
int  $expected_quality 
)

Definition at line 258 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\createTestImageStream(), ILIAS\Filesystem\Util\ImageConversionTest\getImageQualityFromStream(), and ILIAS\Filesystem\Util\ImageConversionTest\getImageTypeFromStream().

262  : void {
263  $resized = $this->images->resizeToFixedSize(
264  $this->createTestImageStream(10, 10),
265  5,
266  5,
267  true,
268  $options
269  );
270 
271  $this->assertEquals($expected_mime_type, $this->getImageTypeFromStream($resized->getStream()));
272  $this->assertEquals($expected_quality, $this->getImageQualityFromStream($resized->getStream()));
273  }
+ Here is the call graph for this function:

◆ testImageOutputOptionSanity()

ILIAS\Filesystem\Util\ImageConversionTest::testImageOutputOptionSanity ( )

Definition at line 275 of file ImageConversionTest.php.

275  : void
276  {
277  $options = new ImageOutputOptions();
278 
279  // Defaults
280  $this->assertEquals('jpg', $options->getFormat());
281  $this->assertEquals(75, $options->getQuality());
282 
283  $png = $options->withPngOutput();
284  $this->assertEquals('png', $png->getFormat());
285  $this->assertEquals('jpg', $options->getFormat()); // original options should not change
286  $png_explicit = $options->withFormat('png');
287  $this->assertEquals('png', $png_explicit->getFormat());
288 
289  $jpg = $options->withJpgOutput();
290  $this->assertEquals('jpg', $jpg->getFormat());
291  $jpg_explicit = $options->withFormat('jpg');
292  $this->assertEquals('jpg', $jpg_explicit->getFormat());
293  $jpeg = $options->withFormat('jpeg');
294  $this->assertEquals('jpg', $jpeg->getFormat());
295 
296  // Quality
297  $low = $options->withQuality(5);
298  $this->assertEquals(5, $low->getQuality());
299  $this->assertEquals(75, $options->getQuality()); // original options should not change
300  }

◆ testImageSquareActualImage()

ILIAS\Filesystem\Util\ImageConversionTest::testImageSquareActualImage ( )

Definition at line 81 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\getImageSizeFromStream().

81  : void
82  {
83  $img = __DIR__ . '/img/robot.jpg';
84  $this->assertFileExists($img);
85  $getimagesize = getimagesize($img);
86  $original_width = $getimagesize[0]; // should be 600
87  $original_height = $getimagesize[1]; // should be 800
88  $this->assertEquals(600, $original_width);
89  $this->assertEquals(800, $original_height);
90 
91  // make tumbnail
92  $original_stream = Streams::ofResource(fopen($img, 'rb'));
93 
94  $thumbnail_converter = $this->images->croppedSquare(
95  $original_stream,
96  200
97  );
98  $this->assertTrue($thumbnail_converter->isOK());
99  $this->assertNull($thumbnail_converter->getThrowableIfAny());
100 
101  $getimagesizefromstring = $this->getImageSizeFromStream($thumbnail_converter->getStream());
102 
103  $this->assertEquals(200, $getimagesizefromstring[self::W]);
104  $this->assertEquals(200, $getimagesizefromstring[self::H]);
105  }
+ Here is the call graph for this function:

◆ testImageThumbnailActualImage()

ILIAS\Filesystem\Util\ImageConversionTest::testImageThumbnailActualImage ( )

Definition at line 54 of file ImageConversionTest.php.

54  : void
55  {
56  $img = __DIR__ . '/img/robot.jpg';
57  $this->assertFileExists($img);
58  $getimagesize = getimagesize($img);
59  $original_width = $getimagesize[0]; // should be 600
60  $original_height = $getimagesize[1]; // should be 800
61  $this->assertEquals(600, $original_width);
62  $this->assertEquals(800, $original_height);
63 
64  // make tumbnail
65  $original_stream = Streams::ofResource(fopen($img, 'rb'));
66 
67  $thumbnail_converter = $this->images->thumbnail(
68  $original_stream,
69  100
70  );
71  $this->assertTrue($thumbnail_converter->isOK());
72  $this->assertNull($thumbnail_converter->getThrowableIfAny());
73  $converted_stream = $thumbnail_converter->getStream();
74 
75  $getimagesizefromstring = getimagesizefromstring((string) $converted_stream);
76 
77  $this->assertEquals(75, $getimagesizefromstring[0]); // width
78  $this->assertEquals(100, $getimagesizefromstring[1]); // height
79  }

◆ testResizeByFixedSize()

ILIAS\Filesystem\Util\ImageConversionTest::testResizeByFixedSize ( int  $width,
int  $height,
int  $final_width,
int  $final_height,
bool  $crop 
)

Definition at line 219 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\createTestImageStream(), and ILIAS\Filesystem\Util\ImageConversionTest\getImageSizeFromStream().

225  : void {
226  $stream = $this->createTestImageStream($width, $height);
227  $dimensions = $this->getImageSizeFromStream($stream);
228  $this->assertEquals($width, $dimensions[self::W]);
229  $this->assertEquals($height, $dimensions[self::H]);
230 
231  $by_fixed = $this->images->resizeToFixedSize($stream, $final_width, $final_height, $crop);
232  $this->assertTrue($by_fixed->isOK());
233  $new_dimensions = $this->getImageSizeFromStream($by_fixed->getStream());
234 
235  $this->assertEquals($final_width, $new_dimensions[self::W]);
236  $this->assertEquals($final_height, $new_dimensions[self::H]);
237  }
+ Here is the call graph for this function:

◆ testResizeToFitHeight()

ILIAS\Filesystem\Util\ImageConversionTest::testResizeToFitHeight ( int  $width,
int  $height,
int  $final_height,
int  $final_width 
)

Definition at line 168 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\createTestImageStream(), and ILIAS\Filesystem\Util\ImageConversionTest\getImageSizeFromStream().

173  : void {
174  $stream = $this->createTestImageStream($width, $height);
175  $dimensions = $this->getImageSizeFromStream($stream);
176  $this->assertEquals($width, $dimensions[self::W]);
177  $this->assertEquals($height, $dimensions[self::H]);
178 
179  // resize to fit
180  $resized = $this->images->resizeByHeight($stream, self::BY_HEIGHT_FINAL);
181  $this->assertTrue($resized->isOK());
182  $new_dimensions = $this->getImageSizeFromStream($resized->getStream());
183 
184  $this->assertEquals($final_width, $new_dimensions[self::W]);
185  $this->assertEquals($final_height, $new_dimensions[self::H]);
186 
187  // check aspect ratio
188  $this->assertEquals(
189  round($width > $height),
190  round($final_width > $final_height)
191  );
192  $this->assertEquals(
193  round($width / $height),
194  round($new_dimensions[self::W] / $new_dimensions[self::H])
195  );
196  $this->assertEquals(
197  $width > $height,
198  $width > $height
199  );
200  $this->assertEquals(
201  $width > $height,
202  $new_dimensions[self::W] > $new_dimensions[self::H]
203  );
204  }
+ Here is the call graph for this function:

◆ testResizeToFitWidth()

ILIAS\Filesystem\Util\ImageConversionTest::testResizeToFitWidth ( int  $width,
int  $height,
int  $final_width,
int  $final_height 
)

Definition at line 118 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\createTestImageStream(), and ILIAS\Filesystem\Util\ImageConversionTest\getImageSizeFromStream().

123  : void {
124  $stream = $this->createTestImageStream($width, $height);
125  $dimensions = $this->getImageSizeFromStream($stream);
126  $this->assertEquals($width, $dimensions[self::W]);
127  $this->assertEquals($height, $dimensions[self::H]);
128 
129  // resize to fit width
130  $resized = $this->images->resizeByWidth($stream, self::BY_WIDTH_FINAL);
131  $this->assertTrue($resized->isOK());
132  $new_dimensions = $this->getImageSizeFromStream($resized->getStream());
133 
134  $this->assertEquals($final_width, $new_dimensions[self::W]);
135  $this->assertEquals($final_height, $new_dimensions[self::H]);
136 
137  // check aspect ratio
138  $this->assertEquals(
139  round($width > $height),
140  round($final_width > $final_height)
141  );
142  $this->assertEquals(
143  round($width / $height),
144  round($new_dimensions[self::W] / $new_dimensions[self::H])
145  );
146  $this->assertEquals(
147  $width > $height,
148  $width > $height
149  );
150  $this->assertEquals(
151  $width > $height,
152  $new_dimensions[self::W] > $new_dimensions[self::H]
153  );
154  }
+ Here is the call graph for this function:

◆ testWriteImage()

ILIAS\Filesystem\Util\ImageConversionTest::testWriteImage ( )

Definition at line 442 of file ImageConversionTest.php.

References ILIAS\Filesystem\Util\ImageConversionTest\createTestImageStream().

442  : void
443  {
444  $img = $this->createTestImageStream(10, 10);
445 
446  $output_path = __DIR__ . '/img/output.jpg';
447  $converter_options = (new ImageConversionOptions())
448  ->withThrowOnError(true)
449  ->withMakeTemporaryFiles(false)
450  ->withFixedDimensions(100, 100)
451  ->withOutputPath($output_path);
452 
453  $output_options = (new ImageOutputOptions())
454  ->withQuality(10)
455  ->withJpgOutput();
456 
457  $converter = new ImageConverter($converter_options, $output_options, $img);
458  $this->assertTrue($converter->isOK());
459 
460  $this->assertFileExists($output_path);
461  $stream = $converter->getStream();
462  $this->assertEquals($output_path, $stream->getMetadata('uri'));
463 
464  unlink($output_path);
465  }
+ Here is the call graph for this function:

◆ testWrongFormats()

ILIAS\Filesystem\Util\ImageConversionTest::testWrongFormats ( string  $format)

Definition at line 312 of file ImageConversionTest.php.

312  : void
313  {
314  $options = new ImageOutputOptions();
315  $this->expectException(\InvalidArgumentException::class);
316  $wrong = $options->withFormat($format);
317  }

◆ testWrongQualities()

ILIAS\Filesystem\Util\ImageConversionTest::testWrongQualities ( int  $quality)

Definition at line 329 of file ImageConversionTest.php.

329  : void
330  {
331  $options = new ImageOutputOptions();
332  $this->expectException(\InvalidArgumentException::class);
333  $wrong = $options->withQuality($quality);
334  }

Field Documentation

◆ $images

Images ILIAS\Filesystem\Util\ImageConversionTest::$images
protected

Definition at line 44 of file ImageConversionTest.php.

◆ BY_HEIGHT_FINAL

const ILIAS\Filesystem\Util\ImageConversionTest::BY_HEIGHT_FINAL = 756
protected

Definition at line 38 of file ImageConversionTest.php.

◆ BY_WIDTH_FINAL

const ILIAS\Filesystem\Util\ImageConversionTest::BY_WIDTH_FINAL = 256
protected

Definition at line 37 of file ImageConversionTest.php.

◆ H

const ILIAS\Filesystem\Util\ImageConversionTest::H = 'height'
protected

Definition at line 40 of file ImageConversionTest.php.

◆ IMAGE_JPEG

const ILIAS\Filesystem\Util\ImageConversionTest::IMAGE_JPEG = 'image/jpeg'
protected

Definition at line 41 of file ImageConversionTest.php.

◆ IMAGE_PNG

const ILIAS\Filesystem\Util\ImageConversionTest::IMAGE_PNG = 'image/png'
protected

Definition at line 42 of file ImageConversionTest.php.

◆ IMAGE_WEBP

const ILIAS\Filesystem\Util\ImageConversionTest::IMAGE_WEBP = 'image/webp'
protected

Definition at line 43 of file ImageConversionTest.php.

◆ W

const ILIAS\Filesystem\Util\ImageConversionTest::W = 'width'
protected

Definition at line 39 of file ImageConversionTest.php.


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