PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / webp-convert / tests / Convert / Converters / ImageMagickTest.php

ImageMagickTest.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/rosell-dk/webp-convert/tests/Convert/Converters/ImageMagickTest.php

64 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WebPConvert - Convert JPEG & PNG to WebP with PHP
4 *
5 * @link https://github.com/rosell-dk/webp-convert
6 * @license MIT
7 */
8
9 namespace WebPConvert\Tests\Convert\Converters;
10
11 use WebPConvert\Convert\Converters\ImageMagick;
12 use WebPConvert\Convert\Exceptions\ConversionFailed\ConverterNotOperationalException;
13 use WebPConvert\Loggers\BufferLogger;
14
15 use PHPUnit\Framework\TestCase;
16
17 class ImageMagickTest extends TestCase
18 {
19
20 public static function getImageFolder()
21 {
22 return realpath(__DIR__ . '/../../images');
23 }
24
25 public static function getImagePath($image)
26 {
27 return self::getImageFolder() . '/' . $image;
28 }
29
30 public function testConvert()
31 {
32 ConverterTestHelper::runAllConvertTests($this, 'ImageMagick');
33 }
34
35 private static function tryThis($test, $source, $options)
36 {
37 $bufferLogger = new BufferLogger();
38
39 try {
40 ImageMagick::convert($source, $source . '.webp', $options, $bufferLogger);
41
42 $test->addToAssertionCount(1);
43 } catch (ConversionFailedException $e) {
44
45 //$bufferLogger->getText()
46 throw $e;
47 } catch (ConverterNotOperationalException $e) {
48 // (SystemRequirementsNotMetException is also a ConverterNotOperationalException)
49 // this is ok.
50 return;
51 }
52 }
53
54 public function testWithNice() {
55 $source = self::getImagePath('test.png');
56 $options = [
57 'use-nice' => true,
58 'encoding' => 'lossless',
59 ];
60 self::tryThis($this, $source, $options);
61 }
62
63 }
64