WebP Express - Version 0.14.20

Version Description

(released: 29 jun 2019)

  • Fixed bug: Ewww api-key was forgot upon saving options (fixed by pcfreak30, USA, reported by viajandocomamalarosa. Thanks!)
  • Cleaned away unneeded files in vendor folders (primarily docs and tests)
Download this release

Release Info

Developer rosell.dk
Plugin Icon 128x128 WebP Express
Version 0.14.20
Comparing to
See all releases

Code changes from version 0.14.19 to 0.14.20

Files changed (32) hide show
  1. README.md +3 -2
  2. README.txt +10 -1
  3. lib/options/submit.php +4 -0
  4. tests/BananaTest.php +0 -24
  5. vendor/autoload.php +1 -1
  6. vendor/composer/autoload_classmap.php +83 -0
  7. vendor/composer/autoload_real.php +4 -4
  8. vendor/composer/autoload_static.php +90 -3
  9. vendor/composer/installed.json +2 -2
  10. vendor/rosell-dk/webp-convert-cloud-service/docs/api.md +0 -103
  11. vendor/rosell-dk/webp-convert-cloud-service/docs/development.md +0 -51
  12. vendor/rosell-dk/webp-convert-cloud-service/tests/WebPConvertCloudServiceTest.php +0 -21
  13. vendor/rosell-dk/webp-convert/docs/development.md +0 -78
  14. vendor/rosell-dk/webp-convert/docs/v1.3/converting/convert-options.md +0 -322
  15. vendor/rosell-dk/webp-convert/docs/v1.3/converting/convert.md +0 -96
  16. vendor/rosell-dk/webp-convert/docs/v1.3/converting/converters.md +0 -322
  17. vendor/rosell-dk/webp-convert/docs/v1.3/serving/convert-and-serve.md +0 -167
  18. vendor/rosell-dk/webp-convert/docs/v1.3/webp-on-demand/tweaks.md +0 -167
  19. vendor/rosell-dk/webp-convert/docs/v1.3/webp-on-demand/webp-on-demand.md +0 -133
  20. vendor/rosell-dk/webp-convert/docs/v1.3/webp-on-demand/without-composer.md +0 -45
  21. vendor/rosell-dk/webp-convert/docs/v2.0/converting/architecture-q50-w600.jpg +0 -0
  22. vendor/rosell-dk/webp-convert/docs/v2.0/converting/converters/stack.md +0 -248
  23. vendor/rosell-dk/webp-convert/docs/v2.0/converting/dice.png +0 -0
  24. vendor/rosell-dk/webp-convert/docs/v2.0/converting/introduction-for-converting.md +0 -218
  25. vendor/rosell-dk/webp-convert/docs/v2.0/converting/mouse-q100.jpg +0 -0
  26. vendor/rosell-dk/webp-convert/docs/v2.0/converting/options.md +0 -319
  27. vendor/rosell-dk/webp-convert/docs/v2.0/migrating-to-2.0.md +0 -73
  28. vendor/rosell-dk/webp-convert/docs/v2.0/serving/introduction-for-serving.md +0 -143
  29. vendor/rosell-dk/webp-convert/docs/v2.0/webp-on-demand/tweaks.md +0 -167
  30. vendor/rosell-dk/webp-convert/docs/v2.0/webp-on-demand/webp-on-demand.md +0 -145
  31. vendor/rosell-dk/webp-convert/docs/v2.0/webp-on-demand/without-composer.md +0 -58
  32. webp-express.php +1 -1
README.md CHANGED
@@ -2,9 +2,10 @@
2
3
Serve autogenerated WebP images instead of jpeg/png to browsers that supports WebP.
4
5
- The plugin is available on the Wordpress codex ([here](https://wordpress.org/plugins/webp-express/)), and developed on github ([here](https://github.com/rosell-dk/webp-express/)).
6
7
- Note that to use the version on github, you need to *cd* into the plugin folder and run `composer update`.
8
9
## Description
10
Almost 4 out of 5 mobile users use a browser that is able to display webp images. Yet, on most websites, they are served jpeg images, which are typically double the size of webp images for a given quality. What a waste of bandwidth! This plugin was created to help remedy that situation. With little effort, Wordpress admins can have their site serving autogenerated webp images to browsers that supports it, while still serving jpeg and png files to browsers that does not support webp.
2
3
Serve autogenerated WebP images instead of jpeg/png to browsers that supports WebP.
4
5
+ The plugin is available on the Wordpress codex ([here](https://wordpress.org/plugins/webp-express/)).
6
+ But well, it is developed ([here on github](https://github.com/rosell-dk/webp-express/)).
7
8
+ **News: I have added the vendor folder to the repo. To install the plugin here from github, you can simply download the zip and unzip it in your plugin folder**
9
10
## Description
11
Almost 4 out of 5 mobile users use a browser that is able to display webp images. Yet, on most websites, they are served jpeg images, which are typically double the size of webp images for a given quality. What a waste of bandwidth! This plugin was created to help remedy that situation. With little effort, Wordpress admins can have their site serving autogenerated webp images to browsers that supports it, while still serving jpeg and png files to browsers that does not support webp.
README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://ko-fi.com/rosell
4
Tags: webp, images, performance
5
Requires at least: 4.0
6
Tested up to: 5.2
7
- Stable tag: 0.14.19
8
Requires PHP: 5.6
9
License: GPLv3
10
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -612,6 +612,12 @@ Easy enough! - [Go here!](https://ko-fi.com/rosell). Or [here](https://buymeacof
612
613
== Changelog ==
614
615
= 0.14.19 =
616
*(released: 28 jun 2019)*
617
@@ -914,6 +920,9 @@ For older releases, check out changelog.txt
914
915
== Upgrade Notice ==
916
917
= 0.14.19 =
918
* Bug fix
919
4
Tags: webp, images, performance
5
Requires at least: 4.0
6
Tested up to: 5.2
7
+ Stable tag: 0.14.20
8
Requires PHP: 5.6
9
License: GPLv3
10
License URI: https://www.gnu.org/licenses/gpl-3.0.html
612
613
== Changelog ==
614
615
+ = 0.14.20 =
616
+ *(released: 29 jun 2019)*
617
+
618
+ * Fixed bug: Ewww api-key was forgot upon saving options (fixed by pcfreak30, USA, reported by viajandocomamalarosa. Thanks!)
619
+ * Cleaned away unneeded files in vendor folders (primarily docs and tests)
620
+
621
= 0.14.19 =
622
*(released: 28 jun 2019)*
623
920
921
== Upgrade Notice ==
922
923
+ = 0.14.20 =
924
+ * Ewww api-key was forgotten upon saving options
925
+
926
= 0.14.19 =
927
* Bug fix
928
lib/options/submit.php CHANGED
@@ -219,6 +219,10 @@ function webpexpress_getSanitizedConverters() {
219
"api-version" => 'integer',
220
"crypt-api-key-in-transfer" => 'boolean',
221
"new-api-key" => 'string',
222
];
223
224
// check that it is an accepted option name
219
"api-version" => 'integer',
220
"crypt-api-key-in-transfer" => 'boolean',
221
"new-api-key" => 'string',
222
+
223
+ //ewww
224
+ "api-key" => 'string',
225
+ "api-key-2" => 'string',
226
];
227
228
// check that it is an accepted option name
tests/BananaTest.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * WebPConvert - Convert JPEG & PNG to WebP with PHP
5
- *
6
- * @link https://github.com/rosell-dk/webp-convert
7
- * @license MIT
8
- */
9
-
10
- namespace WebPExpressTests;
11
-
12
- //use WebPConvert\WebPConvert;
13
- use PHPUnit\Framework\TestCase;
14
- use Sunra\PhpSimple\HtmlDomParser;
15
-
16
- class BananaTest extends TestCase
17
- {
18
-
19
- public function testPotatoPotato()
20
- {
21
- $this->assertEquals('potato', 'potato');
22
- }
23
-
24
- }
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
5
require_once __DIR__ . '/composer/autoload_real.php';
6
7
- return ComposerAutoloaderInit9a5d1d521aac5c1f4f08f3a90858f030::getLoader();
4
5
require_once __DIR__ . '/composer/autoload_real.php';
6
7
+ return ComposerAutoloaderInit8fd167583ae3bd095a84a87a56a51e7c::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -6,4 +6,87 @@ $vendorDir = dirname(dirname(__FILE__));
6
$baseDir = dirname($vendorDir);
7
8
return array(
9
);
6
$baseDir = dirname($vendorDir);
7
8
return array(
9
+ 'DOMUtilForWebP\\ImageUrlReplacer' => $vendorDir . '/rosell-dk/dom-util-for-webp/src/ImageUrlReplacer.php',
10
+ 'DOMUtilForWebP\\PictureTags' => $vendorDir . '/rosell-dk/dom-util-for-webp/src/PictureTags.php',
11
+ 'ImageMimeTypeGuesser\\Detectors\\AbstractDetector' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/AbstractDetector.php',
12
+ 'ImageMimeTypeGuesser\\Detectors\\ExifImageType' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/ExifImageType.php',
13
+ 'ImageMimeTypeGuesser\\Detectors\\FInfo' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/FInfo.php',
14
+ 'ImageMimeTypeGuesser\\Detectors\\GetImageSize' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/GetImageSize.php',
15
+ 'ImageMimeTypeGuesser\\Detectors\\MimeContentType' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/MimeContentType.php',
16
+ 'ImageMimeTypeGuesser\\Detectors\\SniffFirstFourBytes' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/SniffFirstFourBytes.php',
17
+ 'ImageMimeTypeGuesser\\Detectors\\Stack' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/Detectors/Stack.php',
18
+ 'ImageMimeTypeGuesser\\GuessFromExtension' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/GuessFromExtension.php',
19
+ 'ImageMimeTypeGuesser\\ImageMimeTypeGuesser' => $vendorDir . '/rosell-dk/image-mime-type-guesser/src/ImageMimeTypeGuesser.php',
20
+ 'WebPConvertCloudService\\AccessCheck' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/AccessCheck.php',
21
+ 'WebPConvertCloudService\\Serve' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/Serve.php',
22
+ 'WebPConvertCloudService\\WebPConvertCloudService' => $vendorDir . '/rosell-dk/webp-convert-cloud-service/src/WebPConvertCloudService.php',
23
+ 'WebPConvert\\Convert\\ConverterFactory' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/ConverterFactory.php',
24
+ 'WebPConvert\\Convert\\Converters\\AbstractConverter' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/AbstractConverter.php',
25
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\AutoQualityTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/AutoQualityTrait.php',
26
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\DestinationPreparationTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/DestinationPreparationTrait.php',
27
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\LoggerTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/LoggerTrait.php',
28
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\OptionsTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/OptionsTrait.php',
29
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\WarningLoggerTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/WarningLoggerTrait.php',
30
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\CloudConverterTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/CloudConverterTrait.php',
31
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\CurlTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/CurlTrait.php',
32
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\EncodingAutoTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/EncodingAutoTrait.php',
33
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\ExecTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/ExecTrait.php',
34
+ 'WebPConvert\\Convert\\Converters\\Cwebp' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php',
35
+ 'WebPConvert\\Convert\\Converters\\Ewww' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Ewww.php',
36
+ 'WebPConvert\\Convert\\Converters\\Gd' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Gd.php',
37
+ 'WebPConvert\\Convert\\Converters\\Gmagick' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Gmagick.php',
38
+ 'WebPConvert\\Convert\\Converters\\GmagickBinary' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/GmagickBinary.php',
39
+ 'WebPConvert\\Convert\\Converters\\GraphicsMagick' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/GraphicsMagick.php',
40
+ 'WebPConvert\\Convert\\Converters\\ImageMagick' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ImageMagick.php',
41
+ 'WebPConvert\\Convert\\Converters\\Imagick' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Imagick.php',
42
+ 'WebPConvert\\Convert\\Converters\\ImagickBinary' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ImagickBinary.php',
43
+ 'WebPConvert\\Convert\\Converters\\Stack' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Stack.php',
44
+ 'WebPConvert\\Convert\\Converters\\Vips' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Vips.php',
45
+ 'WebPConvert\\Convert\\Converters\\Wpc' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Wpc.php',
46
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailedException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailedException.php',
47
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConversionSkippedException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConversionSkippedException.php',
48
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperationalException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperationalException.php',
49
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperational\\InvalidApiKeyException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperational/InvalidApiKeyException.php',
50
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperational\\SystemRequirementsNotMetException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperational/SystemRequirementsNotMetException.php',
51
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblemsException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblemsException.php',
52
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblems\\CreateDestinationFileException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblems/CreateDestinationFileException.php',
53
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblems\\CreateDestinationFolderException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblems/CreateDestinationFolderException.php',
54
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInputException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInputException.php',
55
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\ConverterNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/ConverterNotFoundException.php',
56
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\InvalidImageTypeException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/InvalidImageTypeException.php',
57
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\TargetNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/TargetNotFoundException.php',
58
+ 'WebPConvert\\Convert\\Helpers\\JpegQualityDetector' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Helpers/JpegQualityDetector.php',
59
+ 'WebPConvert\\Convert\\Helpers\\PhpIniSizes' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Helpers/PhpIniSizes.php',
60
+ 'WebPConvert\\Exceptions\\InvalidInputException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/InvalidInputException.php',
61
+ 'WebPConvert\\Exceptions\\InvalidInput\\InvalidImageTypeException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/InvalidImageTypeException.php',
62
+ 'WebPConvert\\Exceptions\\InvalidInput\\TargetNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/TargetNotFoundException.php',
63
+ 'WebPConvert\\Exceptions\\WebPConvertException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/WebPConvertException.php',
64
+ 'WebPConvert\\Helpers\\InputValidator' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/InputValidator.php',
65
+ 'WebPConvert\\Helpers\\MimeType' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/MimeType.php',
66
+ 'WebPConvert\\Helpers\\PathChecker' => $vendorDir . '/rosell-dk/webp-convert/src/Helpers/PathChecker.php',
67
+ 'WebPConvert\\Loggers\\BaseLogger' => $vendorDir . '/rosell-dk/webp-convert/src/Loggers/BaseLogger.php',
68
+ 'WebPConvert\\Loggers\\BufferLogger' => $vendorDir . '/rosell-dk/webp-convert/src/Loggers/BufferLogger.php',
69
+ 'WebPConvert\\Loggers\\EchoLogger' => $vendorDir . '/rosell-dk/webp-convert/src/Loggers/EchoLogger.php',
70
+ 'WebPConvert\\Options\\ArrayOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/ArrayOption.php',
71
+ 'WebPConvert\\Options\\BooleanOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/BooleanOption.php',
72
+ 'WebPConvert\\Options\\Exceptions\\InvalidOptionTypeException' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Exceptions/InvalidOptionTypeException.php',
73
+ 'WebPConvert\\Options\\Exceptions\\InvalidOptionValueException' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Exceptions/InvalidOptionValueException.php',
74
+ 'WebPConvert\\Options\\Exceptions\\OptionNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Exceptions/OptionNotFoundException.php',
75
+ 'WebPConvert\\Options\\GhostOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/GhostOption.php',
76
+ 'WebPConvert\\Options\\IntegerOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/IntegerOption.php',
77
+ 'WebPConvert\\Options\\IntegerOrNullOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php',
78
+ 'WebPConvert\\Options\\MetadataOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/MetadataOption.php',
79
+ 'WebPConvert\\Options\\Option' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Option.php',
80
+ 'WebPConvert\\Options\\Options' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Options.php',
81
+ 'WebPConvert\\Options\\QualityOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/QualityOption.php',
82
+ 'WebPConvert\\Options\\SensitiveArrayOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/SensitiveArrayOption.php',
83
+ 'WebPConvert\\Options\\SensitiveStringOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/SensitiveStringOption.php',
84
+ 'WebPConvert\\Options\\StringOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/StringOption.php',
85
+ 'WebPConvert\\Serve\\Exceptions\\ServeFailedException' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/Exceptions/ServeFailedException.php',
86
+ 'WebPConvert\\Serve\\Header' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/Header.php',
87
+ 'WebPConvert\\Serve\\Report' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/Report.php',
88
+ 'WebPConvert\\Serve\\ServeConvertedWebP' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/ServeConvertedWebP.php',
89
+ 'WebPConvert\\Serve\\ServeConvertedWebPWithErrorHandling' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/ServeConvertedWebPWithErrorHandling.php',
90
+ 'WebPConvert\\Serve\\ServeFile' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/ServeFile.php',
91
+ 'WebPConvert\\WebPConvert' => $vendorDir . '/rosell-dk/webp-convert/src/WebPConvert.php',
92
);
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
3
// autoload_real.php @generated by Composer
4
5
- class ComposerAutoloaderInit9a5d1d521aac5c1f4f08f3a90858f030
6
{
7
private static $loader;
8
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit9a5d1d521aac5c1f4f08f3a90858f030
19
return self::$loader;
20
}
21
22
- spl_autoload_register(array('ComposerAutoloaderInit9a5d1d521aac5c1f4f08f3a90858f030', 'loadClassLoader'), true, true);
23
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit9a5d1d521aac5c1f4f08f3a90858f030', 'loadClassLoader'));
25
26
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
if ($useStaticLoader) {
28
require_once __DIR__ . '/autoload_static.php';
29
30
- call_user_func(\Composer\Autoload\ComposerStaticInit9a5d1d521aac5c1f4f08f3a90858f030::getInitializer($loader));
31
} else {
32
$map = require __DIR__ . '/autoload_namespaces.php';
33
foreach ($map as $namespace => $path) {
2
3
// autoload_real.php @generated by Composer
4
5
+ class ComposerAutoloaderInit8fd167583ae3bd095a84a87a56a51e7c
6
{
7
private static $loader;
8
19
return self::$loader;
20
}
21
22
+ spl_autoload_register(array('ComposerAutoloaderInit8fd167583ae3bd095a84a87a56a51e7c', 'loadClassLoader'), true, true);
23
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit8fd167583ae3bd095a84a87a56a51e7c', 'loadClassLoader'));
25
26
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
if ($useStaticLoader) {
28
require_once __DIR__ . '/autoload_static.php';
29
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit8fd167583ae3bd095a84a87a56a51e7c::getInitializer($loader));
31
} else {
32
$map = require __DIR__ . '/autoload_namespaces.php';
33
foreach ($map as $namespace => $path) {
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
5
namespace Composer\Autoload;
6
7
- class ComposerStaticInit9a5d1d521aac5c1f4f08f3a90858f030
8
{
9
public static $prefixLengthsPsr4 = array (
10
'W' =>
@@ -41,11 +41,98 @@ class ComposerStaticInit9a5d1d521aac5c1f4f08f3a90858f030
41
),
42
);
43
44
public static function getInitializer(ClassLoader $loader)
45
{
46
return \Closure::bind(function () use ($loader) {
47
- $loader->prefixLengthsPsr4 = ComposerStaticInit9a5d1d521aac5c1f4f08f3a90858f030::$prefixLengthsPsr4;
48
- $loader->prefixDirsPsr4 = ComposerStaticInit9a5d1d521aac5c1f4f08f3a90858f030::$prefixDirsPsr4;
49
50
}, null, ClassLoader::class);
51
}
4
5
namespace Composer\Autoload;
6
7
+ class ComposerStaticInit8fd167583ae3bd095a84a87a56a51e7c
8
{
9
public static $prefixLengthsPsr4 = array (
10
'W' =>
41
),
42
);
43
44
+ public static $classMap = array (
45
+ 'DOMUtilForWebP\\ImageUrlReplacer' => __DIR__ . '/..' . '/rosell-dk/dom-util-for-webp/src/ImageUrlReplacer.php',
46
+ 'DOMUtilForWebP\\PictureTags' => __DIR__ . '/..' . '/rosell-dk/dom-util-for-webp/src/PictureTags.php',
47
+ 'ImageMimeTypeGuesser\\Detectors\\AbstractDetector' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/AbstractDetector.php',
48
+ 'ImageMimeTypeGuesser\\Detectors\\ExifImageType' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/ExifImageType.php',
49
+ 'ImageMimeTypeGuesser\\Detectors\\FInfo' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/FInfo.php',
50
+ 'ImageMimeTypeGuesser\\Detectors\\GetImageSize' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/GetImageSize.php',
51
+ 'ImageMimeTypeGuesser\\Detectors\\MimeContentType' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/MimeContentType.php',
52
+ 'ImageMimeTypeGuesser\\Detectors\\SniffFirstFourBytes' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/SniffFirstFourBytes.php',
53
+ 'ImageMimeTypeGuesser\\Detectors\\Stack' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/Detectors/Stack.php',
54
+ 'ImageMimeTypeGuesser\\GuessFromExtension' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/GuessFromExtension.php',
55
+ 'ImageMimeTypeGuesser\\ImageMimeTypeGuesser' => __DIR__ . '/..' . '/rosell-dk/image-mime-type-guesser/src/ImageMimeTypeGuesser.php',
56
+ 'WebPConvertCloudService\\AccessCheck' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/AccessCheck.php',
57
+ 'WebPConvertCloudService\\Serve' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/Serve.php',
58
+ 'WebPConvertCloudService\\WebPConvertCloudService' => __DIR__ . '/..' . '/rosell-dk/webp-convert-cloud-service/src/WebPConvertCloudService.php',
59
+ 'WebPConvert\\Convert\\ConverterFactory' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/ConverterFactory.php',
60
+ 'WebPConvert\\Convert\\Converters\\AbstractConverter' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/AbstractConverter.php',
61
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\AutoQualityTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/AutoQualityTrait.php',
62
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\DestinationPreparationTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/DestinationPreparationTrait.php',
63
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\LoggerTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/LoggerTrait.php',
64
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\OptionsTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/OptionsTrait.php',
65
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\WarningLoggerTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/WarningLoggerTrait.php',
66
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\CloudConverterTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/CloudConverterTrait.php',
67
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\CurlTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/CurlTrait.php',
68
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\EncodingAutoTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/EncodingAutoTrait.php',
69
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\ExecTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/ExecTrait.php',
70
+ 'WebPConvert\\Convert\\Converters\\Cwebp' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php',
71
+ 'WebPConvert\\Convert\\Converters\\Ewww' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Ewww.php',
72
+ 'WebPConvert\\Convert\\Converters\\Gd' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Gd.php',
73
+ 'WebPConvert\\Convert\\Converters\\Gmagick' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Gmagick.php',
74
+ 'WebPConvert\\Convert\\Converters\\GmagickBinary' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/GmagickBinary.php',
75
+ 'WebPConvert\\Convert\\Converters\\GraphicsMagick' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/GraphicsMagick.php',
76
+ 'WebPConvert\\Convert\\Converters\\ImageMagick' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ImageMagick.php',
77
+ 'WebPConvert\\Convert\\Converters\\Imagick' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Imagick.php',
78
+ 'WebPConvert\\Convert\\Converters\\ImagickBinary' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ImagickBinary.php',
79
+ 'WebPConvert\\Convert\\Converters\\Stack' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Stack.php',
80
+ 'WebPConvert\\Convert\\Converters\\Vips' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Vips.php',
81
+ 'WebPConvert\\Convert\\Converters\\Wpc' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Wpc.php',
82
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailedException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailedException.php',
83
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConversionSkippedException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConversionSkippedException.php',
84
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperationalException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperationalException.php',
85
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperational\\InvalidApiKeyException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperational/InvalidApiKeyException.php',
86
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperational\\SystemRequirementsNotMetException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperational/SystemRequirementsNotMetException.php',
87
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblemsException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblemsException.php',
88
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblems\\CreateDestinationFileException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblems/CreateDestinationFileException.php',
89
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblems\\CreateDestinationFolderException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblems/CreateDestinationFolderException.php',
90
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInputException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInputException.php',
91
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\ConverterNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/ConverterNotFoundException.php',
92
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\InvalidImageTypeException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/InvalidImageTypeException.php',
93
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\TargetNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/TargetNotFoundException.php',
94
+ 'WebPConvert\\Convert\\Helpers\\JpegQualityDetector' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Helpers/JpegQualityDetector.php',
95
+ 'WebPConvert\\Convert\\Helpers\\PhpIniSizes' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Helpers/PhpIniSizes.php',
96
+ 'WebPConvert\\Exceptions\\InvalidInputException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/InvalidInputException.php',
97
+ 'WebPConvert\\Exceptions\\InvalidInput\\InvalidImageTypeException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/InvalidImageTypeException.php',
98
+ 'WebPConvert\\Exceptions\\InvalidInput\\TargetNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/InvalidInput/TargetNotFoundException.php',
99
+ 'WebPConvert\\Exceptions\\WebPConvertException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/WebPConvertException.php',
100
+ 'WebPConvert\\Helpers\\InputValidator' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/InputValidator.php',
101
+ 'WebPConvert\\Helpers\\MimeType' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/MimeType.php',
102
+ 'WebPConvert\\Helpers\\PathChecker' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Helpers/PathChecker.php',
103
+ 'WebPConvert\\Loggers\\BaseLogger' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Loggers/BaseLogger.php',
104
+ 'WebPConvert\\Loggers\\BufferLogger' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Loggers/BufferLogger.php',
105
+ 'WebPConvert\\Loggers\\EchoLogger' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Loggers/EchoLogger.php',
106
+ 'WebPConvert\\Options\\ArrayOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/ArrayOption.php',
107
+ 'WebPConvert\\Options\\BooleanOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/BooleanOption.php',
108
+ 'WebPConvert\\Options\\Exceptions\\InvalidOptionTypeException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Exceptions/InvalidOptionTypeException.php',
109
+ 'WebPConvert\\Options\\Exceptions\\InvalidOptionValueException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Exceptions/InvalidOptionValueException.php',
110
+ 'WebPConvert\\Options\\Exceptions\\OptionNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Exceptions/OptionNotFoundException.php',
111
+ 'WebPConvert\\Options\\GhostOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/GhostOption.php',
112
+ 'WebPConvert\\Options\\IntegerOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/IntegerOption.php',
113
+ 'WebPConvert\\Options\\IntegerOrNullOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php',
114
+ 'WebPConvert\\Options\\MetadataOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/MetadataOption.php',
115
+ 'WebPConvert\\Options\\Option' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Option.php',
116
+ 'WebPConvert\\Options\\Options' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Options.php',
117
+ 'WebPConvert\\Options\\QualityOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/QualityOption.php',
118
+ 'WebPConvert\\Options\\SensitiveArrayOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/SensitiveArrayOption.php',
119
+ 'WebPConvert\\Options\\SensitiveStringOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/SensitiveStringOption.php',
120
+ 'WebPConvert\\Options\\StringOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/StringOption.php',
121
+ 'WebPConvert\\Serve\\Exceptions\\ServeFailedException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/Exceptions/ServeFailedException.php',
122
+ 'WebPConvert\\Serve\\Header' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/Header.php',
123
+ 'WebPConvert\\Serve\\Report' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/Report.php',
124
+ 'WebPConvert\\Serve\\ServeConvertedWebP' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/ServeConvertedWebP.php',
125
+ 'WebPConvert\\Serve\\ServeConvertedWebPWithErrorHandling' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/ServeConvertedWebPWithErrorHandling.php',
126
+ 'WebPConvert\\Serve\\ServeFile' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/ServeFile.php',
127
+ 'WebPConvert\\WebPConvert' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/WebPConvert.php',
128
+ );
129
+
130
public static function getInitializer(ClassLoader $loader)
131
{
132
return \Closure::bind(function () use ($loader) {
133
+ $loader->prefixLengthsPsr4 = ComposerStaticInit8fd167583ae3bd095a84a87a56a51e7c::$prefixLengthsPsr4;
134
+ $loader->prefixDirsPsr4 = ComposerStaticInit8fd167583ae3bd095a84a87a56a51e7c::$prefixDirsPsr4;
135
+ $loader->classMap = ComposerStaticInit8fd167583ae3bd095a84a87a56a51e7c::$classMap;
136
137
}, null, ClassLoader::class);
138
}
vendor/composer/installed.json CHANGED
@@ -155,7 +155,7 @@
155
"test": "Launches the preconfigured PHPUnit"
156
}
157
},
158
- "installation-source": "source",
159
"autoload": {
160
"psr-4": {
161
"WebPConvert\\": "src/"
@@ -226,7 +226,7 @@
226
"test": "Launches the preconfigured PHPUnit"
227
}
228
},
229
- "installation-source": "source",
230
"autoload": {
231
"psr-4": {
232
"WebPConvertCloudService\\": "src/"
155
"test": "Launches the preconfigured PHPUnit"
156
}
157
},
158
+ "installation-source": "dist",
159
"autoload": {
160
"psr-4": {
161
"WebPConvert\\": "src/"
226
"test": "Launches the preconfigured PHPUnit"
227
}
228
},
229
+ "installation-source": "dist",
230
"autoload": {
231
"psr-4": {
232
"WebPConvertCloudService\\": "src/"
vendor/rosell-dk/webp-convert-cloud-service/docs/api.md DELETED
@@ -1,103 +0,0 @@
1
- Conversion is done by requesting the script file you created over http(s) (ie `https://wpc.example.com/wpc.php`).
2
- The following is expected in the POST:
3
-
4
-
5
- ## Get the api version
6
- Getting api version bypasses the access-checks.
7
- ```
8
- curl --form action="api-version" http://wpc.example.com/wpc.php
9
- ```
10
-
11
- It returns the major version of the current release. For release 1.1, it will return '1'.
12
- The method was not available in v0.1.
13
-
14
-
15
- ## Check access
16
- If you have set *require-api-key-to-be-crypted-in-transfer* to `false`, you can test access like this:
17
-
18
- ```
19
- curl --form action="check-access" --form api-key="my dog is white" http://wpc.example.com/wpc.php
20
- ```
21
-
22
- Otherwise, it gets more complicated. You will then have to provide "api-key-crypted" and "salt". "api-key-crypted" must be crypted with blowfish, and with salt stripped off. In php, it is calculated like this:
23
-
24
- ```php
25
- $apiKey = 'my dog is white';
26
- $salt = "whatever-but-make-it-unique-for-each-request";
27
- $cryptedKey = substr(crypt($apiKey, '$2y$10#x27; . $salt . '#x27;), 28);
28
- ```
29
-
30
- ## Converting an image
31
- To convert an image, you must set action to "convert", and supply a file.
32
- The method also accepts an "options" argument (json format), which overrides *webp-convert* options set in the configuration.
33
-
34
- Example:
35
- ```
36
- curl --form action="convert" --form api-key="my dog is white" --form file=@test.jpg http://wpc.example.com/wpc.php > test.webp
37
- ```
38
-
39
- If you get a corrupt file, then it is probably because the output contains an error message. To see it, run the above command again, but remove the piping of the output to a file.
40
-
41
-
42
- ### Usage example (PHP)
43
-
44
- ```php
45
-
46
- function createRandomSaltForBlowfish() {
47
- $salt = '';
48
- $validCharsForSalt = array_merge(
49
- range('A', 'Z'),
50
- range('a', 'z'),
51
- range('0', '9'),
52
- ['.', '/']
53
- );
54
-
55
- for ($i=0; $i<22; $i++) {createRandomSaltForBlowfish
56
- $salt .= $validCharsForSalt[array_rand($validCharsForSalt)];
57
- }
58
- return $salt;
59
- }
60
-
61
- $source = __DIR__ . 'test.jpg';
62
- $destination = __DIR__ . 'test.jpg.webp';
63
- $url = 'http://example.com/wpc.php';
64
- $apiKey = 'my dog is white';
65
-
66
- $salt = createRandomSaltForBlowfish();
67
- // Strip off the first 28 characters (the first 6 are always "$2y$10quot;. The next 22 is the salt)
68
- $apiKeyCrypted = substr(crypt($apiKey, '$2y$10#x27; . $salt . '#x27;), 28);
69
-
70
-
71
- $ch = curl_init();
72
- curl_setopt_array($ch, [
73
- CURLOPT_URL => 'http://example.com/wpc.php',
74
- CURLOPT_POST => 1,
75
- CURLOPT_POSTFIELDS => [
76
- 'action' => 'convert',
77
- 'file' => curl_file_create($source),
78
- 'salt' => $salt,
79
- 'api-key-crypted' => $apiKeyCrypted,
80
- 'options' => json_encode(array(
81
- 'quality' => 'auto',
82
- ))
83
- ],
84
- CURLOPT_BINARYTRANSFER => true,
85
- CURLOPT_RETURNTRANSFER => true,
86
- CURLOPT_HEADER => false,
87
- CURLOPT_SSL_VERIFYPEER => false
88
- ]);
89
-
90
- $response = curl_exec($ch);
91
-
92
- // The WPC cloud service either returns an image or an error message
93
- // Verify that we got an image back.
94
- if (curl_getinfo($ch, CURLINFO_CONTENT_TYPE) == 'application/octet-stream') {
95
- $success = file_put_contents($destination, $response);
96
- }
97
- else {
98
- // show error response
99
- echo $response;
100
- }
101
-
102
- curl_close($ch);
103
- ```
vendor/rosell-dk/webp-convert-cloud-service/docs/development.md DELETED
@@ -1,51 +0,0 @@
1
- # Development
2
-
3
- ## Setting up the environment.
4
-
5
- First, clone the repository:
6
- ```
7
- cd whatever/folder/you/want
8
- git clone https://github.com/rosell-dk/webp-convert.git
9
- ```
10
-
11
- Then install the dev tools with composer:
12
-
13
- ```
14
- composer install
15
- ```
16
-
17
- ## Unit Testing
18
- To run all the unit tests do this:
19
- ```
20
- composer test
21
- ```
22
-
23
- Individual test files can be executed like this:
24
- ```
25
- composer test tests/Converters/WPCTest
26
- composer test tests/Serve/ServeConvertedTest
27
- ```
28
-
29
- ## Coding styles
30
- WebPConvert complies with the [PSR-2](https://www.php-fig.org/psr/psr-2/) coding standard.
31
-
32
- To validate coding style of all files, do this:
33
- ```
34
- composer phpcs src
35
- ```
36
-
37
- To automatically fix the coding style of all files, using [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer), do this:
38
- ```
39
- composer phpcbf src
40
- ```
41
-
42
- Or, alternatively, you can fix with the use the [PHP-CS-FIXER](https://github.com/FriendsOfPHP/PHP-CS-Fixer) library instead:
43
- ```
44
- composer cs-fix
45
- ```
46
-
47
- ## Running all tests in one command
48
- The following script runs the unit tests, checks the coding styles and validates composer.json. Run this before pushing to github
49
- ```
50
- composer ci
51
- ```
vendor/rosell-dk/webp-convert-cloud-service/tests/WebPConvertCloudServiceTest.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- /**
4
- *
5
- * @link https://github.com/rosell-dk/webp-convert-cloud-service
6
- * @license MIT
7
- */
8
-
9
- namespace WebPConvertCloudService\Tests;
10
-
11
- use WebPConvertCloudService\WebPConvertCloudService;
12
- use PHPUnit\Framework\TestCase;
13
-
14
- class WebPConvertCloudServiceTest extends TestCase
15
- {
16
- public function testLogic()
17
- {
18
- $this->assertFalse(false);
19
- }
20
-
21
- }
vendor/rosell-dk/webp-convert/docs/development.md DELETED
@@ -1,78 +0,0 @@
1
- # Development
2
-
3
- ## Setting up the environment.
4
-
5
- First, clone the repository:
6
- ```
7
- cd whatever/folder/you/want
8
- git clone https://github.com/rosell-dk/webp-convert.git
9
- ```
10
-
11
- Then install the dev tools with composer:
12
-
13
- ```
14
- composer install
15
- ```
16
-
17
- ## The builds
18
- For those old-schoolers that prefers one packaged file containing all the code - easily uploaded via ftp - we are maintaining `build/webp-convert.inc`.
19
-
20
- It is an aggregation of all the php files needed, with base classes on top. It also includes the files in vendor/rosell-dk/image-mime-type-guesser.
21
-
22
- We also maintain `build/webp-on-demand-1.inc` (which only consists of a few classes) and `build/webp-on-demand-2.inc` (which is loaded by webp-on-demand-2, when a conversion is needed, and contains the rest of the library).
23
-
24
- Whenever code is changed in `src` - or at least, whenever a new release is released, we must rebuild these files. This can be done like this:
25
-
26
- ```
27
- composer build
28
- ```
29
-
30
- This runs `build-scripts/build-webp-on-demand.php`.
31
- That file needs maintaining when new base classes arrives, new folders, or new dependencies.
32
-
33
-
34
- ## Unit Testing
35
- To run all the unit tests do this:
36
- ```
37
- composer test
38
- ```
39
- This also runs tests on the builds.
40
-
41
-
42
- Individual test files can be executed like this:
43
- ```
44
- composer phpunit tests/Convert/Converters/WPCTest
45
- composer phpunit tests/Serve/ServeConvertedTest
46
- ```
47
-
48
-
49
- ## Coding styles
50
- WebPConvert complies with the [PSR-2](https://www.php-fig.org/psr/psr-2/) coding standard.
51
-
52
- To validate coding style of all files, do this:
53
- ```
54
- composer phpcs src
55
- ```
56
-
57
- To automatically fix the coding style of all files, using [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer), do this:
58
- ```
59
- composer phpcbf src
60
- ```
61
-
62
- Or, alternatively, you can fix with the use the [PHP-CS-FIXER](https://github.com/FriendsOfPHP/PHP-CS-Fixer) library instead:
63
- ```
64
- composer cs-fix
65
- ```
66
-
67
- ## Running all tests in one command
68
- The following script runs the unit tests, checks the coding styles, validates `composer.json` and runs the builds.
69
- Run this before pushing anything to github. "ci" btw stands for *continuous integration*.
70
- ```
71
- composer ci
72
- ```
73
-
74
- ## Generating api docs
75
- Install phpdox and run it in the project root:
76
- ```
77
- phpdox
78
- ```
vendor/rosell-dk/webp-convert/docs/v1.3/converting/convert-options.md DELETED
@@ -1,322 +0,0 @@
1
- # The webp converters
2
-
3
- ## The converters at a glance
4
- When it comes to webp conversion, there is actually only one library in town: *libwebp* from Google. All conversion methods below ultimately uses that very same library for conversion. This means that it does not matter much, which conversion method you use. Whatever works. There is however one thing to take note of, if you set *quality* to *auto*, and your system cannot determine the quality of the source (this requires imagick or gmagick), and you do not have access to install those, then the only way to get quality-detection is to connect to a *wpc* cloud converter. However, with *cwebp*, you can specify the desired reduction (the *size-in-percentage* option) - at the cost of doubling the conversion time. Read more about those considerations in the API.
5
-
6
- Speed-wise, there is too little difference for it to matter, considering that images usually needs to be converted just once. Anyway, here are the results: *cweb* is the fastest (with method=3). *gd* is right behind, merely 3% slower than *cwebp*. *gmagick* are third place, ~8% slower than *cwebp*. *imagick* comes in ~22% slower than *cwebp*. *ewww* depends on connection speed. On my *digital ocean* account, it takes ~2 seconds to upload, convert, and download a tiny image (10 times longer than the local *cwebp*). A 1MB image however only takes ~4.5 seconds to upload, convert and download (1.5 seconds longer). A 2 MB image takes ~5 seconds to convert (only 16% longer than my *cwebp*). The *ewww* thus converts at a very decent speeds. Probably faster than your average shared host. If multiple big images needs to be converted at the same time, *ewww* will probably perform much better than the local converters.
7
-
8
- [`cwebp`](#cwebp) works by executing the *cwebp* binary from Google, which is build upon the *libwebp* (also from Google). That library is actually the only library in town for generating webp images, which means that the other conversion methods ultimately uses that very same library. Which again means that the results using the different methods are very similar. However, with *cwebp*, we have more parameters to tweak than with the rest. We for example have the *method* option, which controls the trade off between encoding speed and the compressed file size and quality. Setting this to max, we can squeeze the images a few percent extra - without loosing quality (the converter is still pretty fast, so in most cases it is probably worth it).
9
-
10
- Of course, as we here have to call a binary directly, *cwebp* requires the *exec* function to be enabled, and that the webserver user is allowed to execute the `cwebp` binary (either at known system locations, or one of the precompiled binaries, that comes with this library).
11
-
12
- [`vips`](#vips) (**new in 2.0**) works by using the vips extension, if available. Vips is great! It offers many webp options, it is fast and installation is easier than imagick and gd, as it does not need to be configured for webp support.
13
-
14
- [`imagick`](#imagick) does not support any special webp options, but is at least able to strip all metadata, if metadata is set to none. Imagick has a very nice feature - that it is able to detect the quality of a jpeg file. This enables it to automatically use same quality for destination as for source, which eliminates the risk of setting quality higher for the destination than for source (the result of that is that the file size gets higher, but the quality remains the same). As the other converters lends this capability from Imagick, this is however no reason for using Imagick rather than the other converters. Requirements: Imagick PHP extension compiled with WebP support
15
-
16
- [`gmagick`](#gmagick) uses the *gmagick* extension. It is very similar to *imagick*. Requirements: Gmagick PHP extension compiled with WebP support.
17
-
18
- [`gd`](#gd) uses the *Gd* extension to do the conversion. The *Gd* extension is pretty common, so the main feature of this converter is that it may work out of the box. It does not support any webp options, and does not support stripping metadata. Requirements: GD PHP extension compiled with WebP support.
19
-
20
- [`wpc`](#wpc) is an open source cloud service for converting images to webp. To use it, you must either install [webp-convert-cloud-service](https://github.com/rosell-dk/webp-convert-cloud-service) directly on a remote server, or install the Wordpress plugin, [WebP Express](https://github.com/rosell-dk/webp-express) in Wordpress. Btw: Beware that upload limits will prevent conversion of big images. The converter checks your *php.ini* settings and abandons upload right away, if an image is larger than your *upload_max_filesize* or your *post_max_size* setting. Requirements: Access to a running service. The service can be installed [directly](https://github.com/rosell-dk/webp-convert-cloud-service) or by using [this Wordpress plugin](https://wordpress.org/plugins/webp-express/)
21
-
22
- [`ewww`](#ewww) is also a cloud service. Not free, but cheap enough to be considered *practically* free. It supports lossless encoding, but this cannot be controlled. *Ewww* always uses lossy encoding for jpeg and lossless for png. For jpegs this is usually a good choice, however, many pngs are compressed better using lossy encoding. As lossless cannot be controlled, the "lossless:auto" option cannot be used for automatically trying both lossy and lossless and picking the smallest file. Also, unfortunately, *ewww* does not support quality=auto, like *wpc*, and it does not support *size-in-percentage* like *cwebp*, either. I have requested such features, and he is considering... As with *wpc*, beware of upload limits. Requirements: A key to the *EWWW Image Optimizer* cloud service. Can be purchaced [here](https://ewww.io/plans/)
23
-
24
- [`stack`](#stack) takes a stack of converters and tries it from the top, until success. The main convert method actually calls this converter. Stacks within stacks are supported (not really needed, though).
25
-
26
-
27
- **Summary:**
28
-
29
- | | cwebp | vips | imagick / gmagick | imagickbinary | gd | ewww |
30
- | ------------------------------------------ | --------- | ------ | ----------------- | ------------- | --------- | ------ |
31
- | supports lossless encoding ? | yes | yes | no | no | no | yes |
32
- | supports lossless auto ? | yes | yes | no | no | no | no |
33
- | supports near-lossless ? | yes | yes | no | no | no | ? |
34
- | supports metadata stripping / preserving | yes | yes | yes | no | no | ? |
35
- | supports setting alpha quality | no | yes | no | no | no | no |
36
- | supports fixed quality (for lossy) | yes | yes | yes | yes | yes | yes |
37
- | supports auto quality without help | no | no | yes | yes | no | no |
38
-
39
-
40
-
41
- *WebPConvert* currently supports the following converters:
42
-
43
- | Converter | Method | Requirements |
44
- | ------------------------------------ | ------------------------------------------------ | -------------------------------------------------- |
45
- | [`cwebp`](#cwebp) | Calls `cwebp` binary directly | `exec()` function *and* that the webserver user has permission to run `cwebp` binary |
46
- | [`vips`](#vips) (new in 2.0) | Vips extension | Vips extension |
47
- | [`imagick`](#imagick) | Imagick extension (`ImageMagick` wrapper) | Imagick PHP extension compiled with WebP support |
48
- | [`gmagick`](#gmagick) | Gmagick extension (`ImageMagick` wrapper) | Gmagick PHP extension compiled with WebP support |
49
- | [`gd`](#gd) | GD Graphics (Draw) extension (`LibGD` wrapper) | GD PHP extension compiled with WebP support |
50
- | [`imagickbinary`](#imagickbinary) | Calls imagick binary directly | exec() and imagick installed and compiled with WebP support |
51
- | [`wpc`](#wpc) | Connects to an open source cloud service | Access to a running service. The service can be installed [directly](https://github.com/rosell-dk/webp-convert-cloud-service) or by using [this Wordpress plugin](https://wordpress.org/plugins/webp-express/).
52
- | [`ewww`](#ewww) | Connects to *EWWW Image Optimizer* cloud service | Purchasing a key |
53
-
54
- ## Installation
55
- Instructions regarding getting the individual converters to work are [on the wiki](https://github.com/rosell-dk/webp-convert/wiki)
56
-
57
- ## cwebp
58
- <table>
59
- <tr><th>Requirements</th><td><code>exec()</code> function and that the webserver has permission to run `cwebp` binary (either found in system path, or a precompiled version supplied with this library)</td></tr>
60
- <tr><th>Performance</th><td>~40-120ms to convert a 40kb image (depending on *method* option)</td></tr>
61
- <tr><th>Reliability</th><td>No problems detected so far!</td></tr>
62
- <tr><th>Availability</th><td>According to ewww docs, requirements are met on surprisingly many webhosts. Look <a href="https://docs.ewww.io/article/43-supported-web-hosts">here</a> for a list</td></tr>
63
- <tr><th>General options supported</th><td>All (`quality`, `metadata`, `lossless`)</td></tr>
64
- <tr><th>Extra options</th><td>`method` (0-6)<br>`use-nice` (boolean)<br>`try-common-system-paths` (boolean)<br> `try-supplied-binary-for-os` (boolean)<br>`autofilter` (boolean)<br>`size-in-percentage` (number / null)<br>`command-line-options` (string)<br>`low-memory` (boolean)</td></tr>
65
- </table>
66
-
67
- [cwebp](https://developers.google.com/speed/webp/docs/cwebp) is a WebP conversion command line converter released by Google. Our implementation ships with precompiled binaries for Linux, FreeBSD, WinNT, Darwin and SunOS. If however a cwebp binary is found in a usual location, that binary will be preferred. It is executed with [exec()](http://php.net/manual/en/function.exec.php).
68
-
69
- In more detail, the implementation does this:
70
- - It is tested whether cwebp is available in a common system path (eg `/usr/bin/cwebp`, ..)
71
- - If not, then supplied binary is selected from `Converters/Binaries` (according to OS) - after validating checksum
72
- - Command-line options are generated from the options
73
- - If [`nice`]( https://en.wikipedia.org/wiki/Nice_(Unix)) command is found on host, binary is executed with low priority in order to save system resources
74
- - Permissions of the generated file are set to be the same as parent folder
75
-
76
- ### Cwebp options
77
-
78
- The following options are supported, besides the general options (such as quality, lossless etc):
79
-
80
- | Option | Type | Default |
81
- | -------------------------- | ------------------------- | -------------------------- |
82
- | autofilter | boolean | false |
83
- | command-line-options | string | '' |
84
- | low-memory | boolean | false |
85
- | method | integer (0-6) | 6 |
86
- | near-lossless | integer (0-100) | 60 |
87
- | size-in-percentage | integer (0-100) (or null) | null |
88
- | rel-path-to-precompiled-binaries | string | './Binaries' |
89
- | size-in-percentage | number (or null) | is_null |
90
- | try-common-system-paths | boolean | true |
91
- | try-supplied-binary-for-os | boolean | true |
92
- | use-nice | boolean | false |
93
-
94
- Descriptions (only of some of the options):
95
-
96
- #### the `autofilter` option
97
- Turns auto-filter on. This algorithm will spend additional time optimizing the filtering strength to reach a well-balanced quality. Unfortunately, it is extremely expensive in terms of computation. It takes about 5-10 times longer to do a conversion. A 1MB picture which perhaps typically takes about 2 seconds to convert, will takes about 15 seconds to convert with auto-filter. So in most cases, you will want to leave this at its default, which is off.
98
-
99
- #### the `command-line-options` option
100
- This allows you to set any parameter available for cwebp in the same way as you would do when executing *cwebp*. You could ie set it to "-sharpness 5 -mt -crop 10 10 40 40". Read more about all the available parameters in [the docs](https://developers.google.com/speed/webp/docs/cwebp)
101
-
102
- #### the `low-memory` option
103
- Reduce memory usage of lossy encoding at the cost of ~30% longer encoding time and marginally larger output size. Default: `false`. Read more in [the docs](https://developers.google.com/speed/webp/docs/cwebp). Default: *false*
104
-
105
- #### The `method` option
106
- This parameter controls the trade off between encoding speed and the compressed file size and quality. Possible values range from 0 to 6. 0 is fastest. 6 results in best quality.
107
-
108
- #### the `near-lossless` option
109
- Specify the level of near-lossless image preprocessing. This option adjusts pixel values to help compressibility, but has minimal impact on the visual quality. It triggers lossless compression mode automatically. The range is 0 (maximum preprocessing) to 100 (no preprocessing). The typical value is around 60. Read more [here](https://groups.google.com/a/webmproject.org/forum/#!topic/webp-discuss/0GmxDmlexek). Default: 60
110
-
111
- #### The `size-in-percentage` option
112
- This option sets the file size, *cwebp* should aim for, in percentage of the original. If you for example set it to *45*, and the source file is 100 kb, *cwebp* will try to create a file with size 45 kb (we use the `-size` option). This is an excellent alternative to the "quality:auto" option. If the quality detection isn't working on your system (and you do not have the rights to install imagick or gmagick), you should consider using this options instead. *Cwebp* is generally able to create webp files with the same quality at about 45% the size. So *45* would be a good choice. The option overrides the quality option. And note that it slows down the conversion - it takes about 2.5 times longer to do a conversion this way, than when quality is specified. Default is *off* (null)
113
-
114
-
115
- #### final words on cwebp
116
- The implementation is based on the work of Shane Bishop for his plugin, [EWWW Image Optimizer](https://ewww.io). Thanks for letting us do that!
117
-
118
- See [the wiki](https://github.com/rosell-dk/webp-convert/wiki/Installing-cwebp---using-official-precompilations) for instructions regarding installing cwebp or using official precompilations.
119
-
120
- ## vips
121
- <table>
122
- <tr><th>Requirements</th><td>Vips extension</td></tr>
123
- <tr><th>Performance</th><td>Great</td></tr>
124
- <tr><th>Reliability</th><td>No problems detected so far!</td></tr>
125
- <tr><th>Availability</th><td>Not that widespread yet, but gaining popularity</td></tr>
126
- <tr><th>General options supported</th><td>All (`quality`, `metadata`, `lossless`)</td></tr>
127
- <tr><th>Extra options</th><td>`smart-subsample`(boolean)<br>`alpha-quality`(0-100)<br>`near-lossless` (0-100)<br> `preset` (0-6)</td></tr>
128
- </table>
129
-
130
- For installation instructions, go [here](https://github.com/libvips/php-vips-ext).
131
-
132
- The options are described [here](https://jcupitt.github.io/libvips/API/current/VipsForeignSave.html#vips-webpsave)
133
-
134
- *near-lossless* is however an integer (0-100), in order to have the option behave like in cwebp.
135
-
136
-
137
-
138
- ## wpc
139
- *WebPConvert Cloud Service*
140
-
141
- <table>
142
- <tr><th>Requirements</th><td>Access to a server with [webp-convert-cloud-service](https://github.com/rosell-dk/webp-convert-cloud-service) installed, <code>cURL</code> and PHP >= 5.5.0</td></tr>
143
- <tr><th>Performance</th><td>Depends on the server where [webp-convert-cloud-service](https://github.com/rosell-dk/webp-convert-cloud-service) is set up, and the speed of internet connections. But perhaps ~1000ms to convert a 40kb image</td></tr>
144
- <tr><th>Reliability</th><td>Great (depends on the reliability on the server where it is set up)</td></tr>
145
- <tr><th>Availability</th><td>Should work on <em>almost</em> any webhost</td></tr>
146
- <tr><th>General options supported</th><td>All (`quality`, `metadata`, `lossless`)</td></tr>
147
- <tr><th>Extra options (old api)</th><td>`url`, `secret`</td></tr>
148
- <tr><th>Extra options (new api)</th><td>`url`, `api-version`, `api-key`, `crypt-api-key-in-transfer`</td></tr>
149
- </table>
150
-
151
- [wpc](https://github.com/rosell-dk/webp-convert-cloud-service) is an open source cloud service. You do not buy a key, you set it up on a server, or you set up [the Wordpress plugin](https://wordpress.org/plugins/webp-express/). As WebPConvert Cloud Service itself is based on WebPConvert, all options are supported.
152
-
153
- To use it, you need to set the `converter-options` (to add url etc).
154
-
155
- #### Example, where api-key is not crypted, on new API:
156
-
157
- ```php
158
- WebPConvert::convert($source, $destination, [
159
- 'max-quality' => 80,
160
- 'converters' => ['cwebp', 'wpc'],
161
- 'converter-options' => [
162
- 'wpc' => [
163
- 'api-version' => 1, /* from wpc release 1.0.0 */
164
- 'url' => 'http://example.com/wpc.php',
165
- 'api-key' => 'my dog is white',
166
- 'crypt-api-key-in-transfer' => false
167
- ]
168
- ]
169
- ));
170
- ```
171
-
172
- #### Example, where api-key is crypted:
173
-
174
- ```php
175
-
176
- WebPConvert::convert($source, $destination, [
177
- 'max-quality' => 80,
178
- 'converters' => ['cwebp', 'wpc'],
179
- 'converter-options' => [
180
- 'wpc' => [
181
- 'api-version' => 1,
182
- 'url' => 'https://example.com/wpc.php',
183
- 'api-key' => 'my dog is white',
184
- 'crypt-api-key-in-transfer' => true
185
- ],
186
- ]
187
- ));
188
- ```
189
-
190
- In 2.0, you can alternatively set the api key and urls through through the *WPC_API_KEY* and *WPC_API_URL* environment variables. This is a safer place to store it.
191
-
192
- To set an environment variable in Apache, you can use the `SetEnv` directory. Ie, place something like the following in your virtual host / or .htaccess file (replace the key with the one you purchased!)
193
-
194
- ```
195
- SetEnv WPC_API_KEY my-dog-is-dashed
196
- SetEnv WPC_API_URL https://wpc.example.com/wpc.php
197
- ```
198
-
199
-
200
- #### Example, old API:
201
-
202
- ```php
203
- WebPConvert::convert($source, $destination, [
204
- 'max-quality' => 80,
205
- 'converters' => ['cwebp', 'wpc'],
206
- 'converter-options' => [
207
- 'wpc' => [
208
- 'url' => 'https://example.com/wpc.php',
209
- 'secret' => 'my dog is white',
210
- ],
211
- ]
212
- ));
213
- ```
214
-
215
-
216
- ## ewww
217
-
218
- <table>
219
- <tr><th>Requirements</th><td>Valid EWWW Image Optimizer <a href="https://ewww.io/plans/">API key</a>, <code>cURL</code> and PHP >= 5.5.0</td></tr>
220
- <tr><th>Performance</th><td>~1300ms to convert a 40kb image</td></tr>
221
- <tr><th>Reliability</th><td>Great (but, as with any cloud service, there is a risk of downtime)</td></tr>
222
- <tr><th>Availability</th><td>Should work on <em>almost</em> any webhost</td></tr>
223
- <tr><th>General options supported</th><td>`quality`, `metadata` (partly)</td></tr>
224
- <tr><th>Extra options</th><td>`key`</td></tr>
225
- </table>
226
-
227
- EWWW Image Optimizer is a very cheap cloud service for optimizing images. After purchasing an API key, add the converter in the `extra-converters` option, with `key` set to the key. Be aware that the `key` should be stored safely to avoid exploitation - preferably in the environment, ie with [dotenv](https://github.com/vlucas/phpdotenv).
228
-
229
- The EWWW api doesn't support the `lossless` option, but it does automatically convert PNG's losslessly. Metadata is either all or none. If you have set it to something else than one of these, all metadata will be preserved.
230
-
231
- In more detail, the implementation does this:
232
- - Validates that there is a key, and that `curl` extension is working
233
- - Validates the key, using the [/verify/ endpoint](https://ewww.io/api/) (in order to [protect the EWWW service from unnecessary file uploads, when key has expired](https://github.com/rosell-dk/webp-convert/issues/38))
234
- - Converts, using the [/ endpoint](https://ewww.io/api/).
235
-
236
- <details>
237
- <summary><strong>Roadmap</strong> 👁</summary>
238
-
239
- The converter could be improved by using `fsockopen` when `cURL` is not available - which is extremely rare. PHP >= 5.5.0 is also widely available (PHP 5.4.0 reached end of life [more than two years ago!](http://php.net/supported-versions.php)).
240
- </details>
241
-
242
- #### Example:
243
-
244
- ```php
245
- WebPConvert::convert($source, $destination, [
246
- 'max-quality' => 80,
247
- 'converters' => ['gd', 'ewww'],
248
- 'converter-options' => [
249
- 'ewww' => [
250
- 'key' => 'your-api-key-here'
251
- ],
252
- ]
253
- ));
254
- ```
255
- In 2.0, you can alternatively set the api key by through the *EWWW_API_KEY* environment variable. This is a safer place to store it.
256
-
257
- To set an environment variable in Apache, you can use the `SetEnv` directory. Ie, place something like the following in your virtual host / or .htaccess file (replace the key with the one you purchased!)
258
-
259
- ```
260
- SetEnv EWWW_API_KEY sP3LyPpsKWZy8CVBTYegzEGN6VsKKKKA
261
- ```
262
-
263
- ## gd
264
-
265
- <table>
266
- <tr><th>Requirements</th><td>GD PHP extension and PHP >= 5.5.0 (compiled with WebP support)</td></tr>
267
- <tr><th>Performance</th><td>~30ms to convert a 40kb image</td></tr>
268
- <tr><th>Reliability</th><td>Not sure - I have experienced corrupted images, but cannot reproduce</td></tr>
269
- <tr><th>Availability</th><td>Unfortunately, according to <a href="https://stackoverflow.com/questions/25248382/how-to-create-a-webp-image-in-php">this link</a>, WebP support on shared hosts is rare.</td></tr>
270
- <tr><th>General options supported</th><td>`quality`</td></tr>
271
- <tr><th>Extra options</th><td>`skip-pngs`</td></tr>
272
- </table>
273
-
274
- [imagewebp](http://php.net/manual/en/function.imagewebp.php) is a function that comes with PHP (>5.5.0), *provided* that PHP has been compiled with WebP support.
275
-
276
- `gd` neither supports copying metadata nor exposes any WebP options. Lacking the option to set lossless encoding results in poor encoding of PNGs - the filesize is generally much larger than the original. For this reason, PNG conversion is *disabled* by default, but it can be enabled my setting `skip-pngs` option to `false`.
277
-
278
- Installaition instructions are [available in the wiki](https://github.com/rosell-dk/webp-convert/wiki/Installing-Gd-extension).
279
-
280
- <details>
281
- <summary><strong>Known bugs</strong> 👁</summary>
282
- Due to a [bug](https://bugs.php.net/bug.php?id=66590), some versions sometimes created corrupted images. That bug can however easily be fixed in PHP (fix was released [here](https://stackoverflow.com/questions/30078090/imagewebp-php-creates-corrupted-webp-files)). However, I have experienced corrupted images *anyway* (but cannot reproduce that bug). So use this converter with caution. The corrupted images look completely transparent in Google Chrome, but have the correct size.
283
- </details>
284
-
285
- ## imagick
286
-
287
- <table>
288
- <tr><th>Requirements</th><td>Imagick PHP extension (compiled with WebP support)</td></tr>
289
- <tr><th>Quality</th><td>Poor. [See this issue]( https://github.com/rosell-dk/webp-convert/issues/43)</td></tr>
290
- <tr><th>General options supported</th><td>`quality`</td></tr>
291
- <tr><th>Extra options</th><td>None</td></tr>
292
- <tr><th>Performance</th><td>~20-320ms to convert a 40kb image</td></tr>
293
- <tr><th>Reliability</th><td>No problems detected so far</td></tr>
294
- <tr><th>Availability</th><td>Probably only available on few shared hosts (if any)</td></tr>
295
- </table>
296
-
297
- WebP conversion with `imagick` is fast and [exposes many WebP options](http://www.imagemagick.org/script/webp.php). Unfortunately, WebP support for the `imagick` extension is pretty uncommon. At least not on the systems I have tried (Ubuntu 16.04 and Ubuntu 17.04). But if installed, it works great and has several WebP options.
298
-
299
- See [this page](https://github.com/rosell-dk/webp-convert/wiki/Installing-Imagick-extension) in the Wiki for instructions on installing the extension.
300
-
301
- ## imagickbinary
302
- <table>
303
- <tr><th>Requirements</th><td><code>exec()</code> function and that imagick is installed on webserver, compiled with webp support</td></tr>
304
- <tr><th>Performance</th><td>just fine</td></tr>
305
- <tr><th>Reliability</th><td>No problems detected so far!</td></tr>
306
- <tr><th>Availability</th><td>Not sure</td></tr>
307
- <tr><th>General options supported</th><td>`quality`</td></tr>
308
- <tr><th>Extra options</th><td>`use-nice` (boolean)</td></tr>
309
- </table>
310
-
311
- This converter tryes to execute `convert source.jpg webp:destination.jpg.webp`.
312
-
313
- ## stack
314
-
315
- <table>
316
- <tr><th>General options supported</th><td>all (passed to the converters in the stack )</td></tr>
317
- <tr><th>Extra options</th><td>`converters` (array) and `converter-options` (array)</td></tr>
318
- </table>
319
-
320
- Stack implements the functionality you know from `WebPConvert::convert`. In fact, all `WebPConvert::convert` does is to call `Stack::convert($source, $destination, $options, $logger);`
321
-
322
- It has two special options: `converters` and `converter-options`. You can read about those in `docs/api/convert.md`
vendor/rosell-dk/webp-convert/docs/v1.3/converting/convert.md DELETED
@@ -1,96 +0,0 @@
1
- # API: The convert() method
2
-
3
- **WebPConvert::convert($source, $destination, $options, $logger)**
4
-
5
- | Parameter | Type | Description |
6
- | ---------------- | ------- | ------------------------------------------------------------------------------------------ |
7
- | `$source` | String | Absolute path to source image (only forward slashes allowed) |
8
- | `$destination` | String | Absolute path to converted image (only forward slashes allowed) |
9
- | `$options` (optional) | Array | Array of conversion (option) options |
10
- | `$logger` (optional) | Baselogger | Information about the conversion process will be passed to this object. Read more below |
11
-
12
- Returns true if success or false if no converters are *operational*. If any converter seems to have its requirements met (are *operational*), but fails anyway, and no other converters in the stack could convert the image, an the exception from that converter is rethrown (either *ConverterFailedException* or *ConversionDeclinedException*). Exceptions are also thrown if something is wrong entirely (*InvalidFileExtensionException*, *TargetNotFoundException*, *ConverterNotFoundException*, *CreateDestinationFileException*, *CreateDestinationFolderException*, or any unanticipated exceptions thrown by the converters).
13
-
14
- ### Available options for all converters
15
-
16
- Many options correspond to options of *cwebp*. These are documented [here](https://developers.google.com/speed/webp/docs/cwebp)
17
-
18
-
19
- | Option | Type | Default | Description |
20
- | ----------------- | ------- | -------------------------- | -------------------------------------------------------------------- |
21
- | quality | An integer between 0-100, or "auto" | "auto" | Lossy quality of converted image (JPEG only - PNGs are always losless).<br><br> If set to "auto", *WebPConvert* will try to determine the quality of the JPEG (this is only possible, if Imagick or GraphicsMagic is installed). If successfully determined, the quality of the webp will be set to the same as that of the JPEG. however not to more than specified in the new `max-quality` option. If quality cannot be determined, quality will be set to what is specified in the new `default-quality` option (however, if you use the *wpc* converter, it will also get a shot at detecting the quality) |
22
- | max-quality | An integer between 0-100 | 85 | See the `quality` option. Only relevant, when quality is set to "auto".
23
- | default-quality | An integer between 0-100 | 75 | See the `quality` option. Only relevant, when quality is set to "auto".
24
- | metadata | String | 'none' | Valid values: all, none, exif, icc, xmp. Note: Only *cwebp* supports all values. *gd* will always remove all metadata. *ewww*, *imagick* and *gmagick* can either strip all, or keep all (they will keep all, unless metadata is set to *none*) |
25
- | lossless | Boolean | false ("auto" for pngs in 2.0) | Encode the image without any loss. The option is ignored for PNG's (forced true). In 2.0, it can also be "auto", and it is not forced to anything - rather it deafaults to false for Jpegs and "auto" for PNGs |
26
- | converters | Array | ['cwebp', 'gd', 'imagick'] | Specify conversion methods to use, and their order. Also optionally set converter options (see below) |
27
- | converter-options | Array | [] | Set options of the individual converters (see below) |
28
- | jpeg | Array | null | These options will be merged into the other options when source is jpeg |
29
- | png | Array | null | These options will be merged into the other options when source is jpeg |
30
- | skip (new in 2.0) | Boolean | false | If true, conversion will be skipped (ie for skipping png conversion for some converters) |
31
- | skip-png (removed in 2.0) | Boolean | false | If true, conversion will be skipped for png (ie for skipping png conversion for some converters) |
32
-
33
- #### More on quality=auto
34
- Unfortunately, *libwebp* does not provide a way to use the same quality for the converted image, as for source. This feature is implemented by *imagick* and *gmagick*. No matter which conversion method you choose, if you set *quality* to *auto*, our library will try to detect the quality of the source file using one of these libraries. If this isn't available, it will revert to the value set in the *default-quality* option (75 per default). *However*, with the *wpc* converter you have a second chance: If quality cannot be detected locally, it will send quality="auto" to *wpc*.
35
-
36
- The bottom line is: If you do not have imagick or gmagick installed on your host (and have no way to install it), your best option quality-wise is to install *wpc* on a server that you do have access to, and connect to that. However,... read on:
37
-
38
- **How much does it matter?**
39
- The effect of not having quality detection is that jpeg images with medium quality (say 50) will be converted with higher quality (say 75). Converting a q=50 to a q=50 would typically result in a ~60% reduction. But converting it to q=75 will only result in a ~45% reduction. When converting low quality jpeg images, it gets worse. Converting q=30 to q=75 only achieves ~25% reduction.
40
-
41
- I guess it is a rare case having jpeg images in low quality. Even having middle quality is rare, as there seems to have been a tendency to choose higher quality than actually needed for web. So, in many cases, the impact of not having quality detection is minor. If you set the *default-quality* a bit low, ie 65, you will further minimize the effect.
42
-
43
- To determine if *webp-convert* is able to autodetect quality on your system, run a conversion with the *$logger* parameter set to `new EchoLogger()` (see api).
44
-
45
- #### More on the `converter-options` option
46
- You use this option to set options for the individual converters. Example:
47
-
48
- ```
49
- 'converter-options' => [
50
- 'ewww' => [
51
- 'key' => 'your-api-key-here'
52
- ],
53
- 'wpc' => [
54
- 'url' => 'https://example.com/wpc.php',
55
- 'secret' => 'my dog is white'
56
- ]
57
- ]
58
- ```
59
- Besides options that are special to a converter, you can also override general options. For example, you may generally want the `max-quality` to be 85, but for a single converter, you would like it to be 100 (sorry, it is hard to come up with a useful example).
60
-
61
- #### More on the `converters` option
62
- The *converters* option specifies the conversion methods to use and their order. But it can also be used as an alternative way of setting converter options. Usually, you probably want to use the *converter-options* for that, but there may be cases where it is more convenient to specify them here. Also, specifying here allows you to put the same converter method to the stack multiple times, with different options (this could for example be used to have an extra *ewww* converter as a fallback).
63
-
64
- Example:
65
- ```
66
- WebPConvert::convert($source, $destination, [
67
- 'converters' => [
68
- 'cwebp',
69
- 'imagick',
70
- [
71
- 'converter' => 'ewww',
72
- 'options' => [
73
- 'key' => 'your api key here',
74
- ],
75
- ],
76
- ];
77
- )
78
- ```
79
- In 2.0, it will be possible to use your own custom converter. Instead of the "converter id" (ie "ewww"), specify the full class name of your custom converter. Ie '\\MyProject\\BraveConverter'. The converter must extend `\WebPConvert\Convert\Converters\AbstractConverters\AbstractConverter` and you must implement `doConvert()` and the define the extra options it takes (check out how it is done in the build-in converters).
80
-
81
- ### More on the `$logger` parameter
82
- WebPConvert and the individual converters can provide information regarding the conversion process. Per default (when the parameter isn't provided), they write this to `\WebPConvert\Loggers\VoidLogger`, which does nothing with it.
83
- In order to get this information echoed out, you can use `\WebPConvert\Loggers\EchoLogger` - like this:
84
-
85
- ```php
86
- use WebPConvert\Loggers\EchoLogger;
87
-
88
- WebPConvert::convert($source, $destination, $options, new EchoLogger());
89
- ```
90
-
91
- In order to do something else with the information (perhaps write it to a log file?), you can extend `\WebPConvert\Loggers\BaseLogger`.
92
-
93
- ## Converters
94
- In the most basic design, a converter consists of a static convert function which takes the same arguments as `WebPConvert::convert`. Its job is then to convert `$source` to WebP and save it at `$destination`, preferably taking the options specified in $options into account.
95
-
96
- The converters may be called directly. But you probably don't want to do that, as it really doesn't hurt having other converters ready to take over, in case your preferred converter should fail.
vendor/rosell-dk/webp-convert/docs/v1.3/converting/converters.md DELETED
@@ -1,322 +0,0 @@
1
- # The webp converters
2
-
3
- ## The converters at a glance
4
- When it comes to webp conversion, there is actually only one library in town: *libwebp* from Google. All conversion methods below ultimately uses that very same library for conversion. This means that it does not matter much, which conversion method you use. Whatever works. There is however one thing to take note of, if you set *quality* to *auto*, and your system cannot determine the quality of the source (this requires imagick or gmagick), and you do not have access to install those, then the only way to get quality-detection is to connect to a *wpc* cloud converter. However, with *cwebp*, you can specify the desired reduction (the *size-in-percentage* option) - at the cost of doubling the conversion time. Read more about those considerations in the API.
5
-
6
- Speed-wise, there is too little difference for it to matter, considering that images usually needs to be converted just once. Anyway, here are the results: *cweb* is the fastest (with method=3). *gd* is right behind, merely 3% slower than *cwebp*. *gmagick* are third place, ~8% slower than *cwebp*. *imagick* comes in ~22% slower than *cwebp*. *ewww* depends on connection speed. On my *digital ocean* account, it takes ~2 seconds to upload, convert, and download a tiny image (10 times longer than the local *cwebp*). A 1MB image however only takes ~4.5 seconds to upload, convert and download (1.5 seconds longer). A 2 MB image takes ~5 seconds to convert (only 16% longer than my *cwebp*). The *ewww* thus converts at a very decent speeds. Probably faster than your average shared host. If multiple big images needs to be converted at the same time, *ewww* will probably perform much better than the local converters.
7
-
8
- [`cwebp`](#cwebp) works by executing the *cwebp* binary from Google, which is build upon the *libwebp* (also from Google). That library is actually the only library in town for generating webp images, which means that the other conversion methods ultimately uses that very same library. Which again means that the results using the different methods are very similar. However, with *cwebp*, we have more parameters to tweak than with the rest. We for example have the *method* option, which controls the trade off between encoding speed and the compressed file size and quality. Setting this to max, we can squeeze the images a few percent extra - without loosing quality (the converter is still pretty fast, so in most cases it is probably worth it).
9
-
10
- Of course, as we here have to call a binary directly, *cwebp* requires the *exec* function to be enabled, and that the webserver user is allowed to execute the `cwebp` binary (either at known system locations, or one of the precompiled binaries, that comes with this library).
11
-
12
- [`vips`](#vips) (**new in 2.0**) works by using the vips extension, if available. Vips is great! It offers many webp options, it is fast and installation is easier than imagick and gd, as it does not need to be configured for webp support.
13
-
14
- [`imagick`](#imagick) does not support any special webp options, but is at least able to strip all metadata, if metadata is set to none. Imagick has a very nice feature - that it is able to detect the quality of a jpeg file. This enables it to automatically use same quality for destination as for source, which eliminates the risk of setting quality higher for the destination than for source (the result of that is that the file size gets higher, but the quality remains the same). As the other converters lends this capability from Imagick, this is however no reason for using Imagick rather than the other converters. Requirements: Imagick PHP extension compiled with WebP support
15
-
16
- [`gmagick`](#gmagick) uses the *gmagick* extension. It is very similar to *imagick*. Requirements: Gmagick PHP extension compiled with WebP support.
17
-
18
- [`gd`](#gd) uses the *Gd* extension to do the conversion. The *Gd* extension is pretty common, so the main feature of this converter is that it may work out of the box. It does not support any webp options, and does not support stripping metadata. Requirements: GD PHP extension compiled with WebP support.
19
-
20
- [`wpc`](#wpc) is an open source cloud service for converting images to webp. To use it, you must either install [webp-convert-cloud-service](https://github.com/rosell-dk/webp-convert-cloud-service) directly on a remote server, or install the Wordpress plugin, [WebP Express](https://github.com/rosell-dk/webp-express) in Wordpress. Btw: Beware that upload limits will prevent conversion of big images. The converter checks your *php.ini* settings and abandons upload right away, if an image is larger than your *upload_max_filesize* or your *post_max_size* setting. Requirements: Access to a running service. The service can be installed [directly](https://github.com/rosell-dk/webp-convert-cloud-service) or by using [this Wordpress plugin](https://wordpress.org/plugins/webp-express/)
21
-
22
- [`ewww`](#ewww) is also a cloud service. Not free, but cheap enough to be considered *practically* free. It supports lossless encoding, but this cannot be controlled. *Ewww* always uses lossy encoding for jpeg and lossless for png. For jpegs this is usually a good choice, however, many pngs are compressed better using lossy encoding. As lossless cannot be controlled, the "lossless:auto" option cannot be used for automatically trying both lossy and lossless and picking the smallest file. Also, unfortunately, *ewww* does not support quality=auto, like *wpc*, and it does not support *size-in-percentage* like *cwebp*, either. I have requested such features, and he is considering... As with *wpc*, beware of upload limits. Requirements: A key to the *EWWW Image Optimizer* cloud service. Can be purchaced [here](https://ewww.io/plans/)
23
-
24
- [`stack`](#stack) takes a stack of converters and tries it from the top, until success. The main convert method actually calls this converter. Stacks within stacks are supported (not really needed, though).
25
-
26
-
27
- **Summary:**
28
-
29
- | | cwebp | vips | imagickbinary | imagick / gmagick | gd | ewww |
30
- | ------------------------------------------ | --------- | ------ | -------------- | ----------------- | --------- | ------ |
31
- | supports lossless encoding ? | yes | yes | yes | no | no | yes |
32
- | supports lossless auto ? | yes | yes | yes | no | no | no |
33
- | supports near-lossless ? | yes | yes | no | no | no | ? |
34
- | supports metadata stripping / preserving | yes | yes | yes | yes | no | ? |
35
- | supports setting alpha quality | yes | yes | yes | no | no | no |
36
- | supports fixed quality (for lossy) | yes | yes | yes | yes | yes | yes |
37
- | supports auto quality without help | no | no | yes | yes | no | no |
38
-
39
-
40
-
41
- *WebPConvert* currently supports the following converters:
42
-
43
- | Converter | Method | Requirements |
44
- | ------------------------------------ | ------------------------------------------------ | -------------------------------------------------- |
45
- | [`cwebp`](#cwebp) | Calls `cwebp` binary directly | `exec()` function *and* that the webserver user has permission to run `cwebp` binary |
46
- | [`vips`](#vips) (new in 2.0) | Vips extension | Vips extension |
47
- | [`imagick`](#imagick) | Imagick extension (`ImageMagick` wrapper) | Imagick PHP extension compiled with WebP support |
48
- | [`gmagick`](#gmagick) | Gmagick extension (`ImageMagick` wrapper) | Gmagick PHP extension compiled with WebP support |
49
- | [`gd`](#gd) | GD Graphics (Draw) extension (`LibGD` wrapper) | GD PHP extension compiled with WebP support |
50
- | [`imagickbinary`](#imagickbinary) | Calls imagick binary directly | exec() and imagick installed and compiled with WebP support |
51
- | [`wpc`](#wpc) | Connects to an open source cloud service | Access to a running service. The service can be installed [directly](https://github.com/rosell-dk/webp-convert-cloud-service) or by using [this Wordpress plugin](https://wordpress.org/plugins/webp-express/).
52
- | [`ewww`](#ewww) | Connects to *EWWW Image Optimizer* cloud service | Purchasing a key |
53
-
54
- ## Installation
55
- Instructions regarding getting the individual converters to work are [on the wiki](https://github.com/rosell-dk/webp-convert/wiki)
56
-
57
- ## cwebp
58
- <table>
59
- <tr><th>Requirements</th><td><code>exec()</code> function and that the webserver has permission to run `cwebp` binary (either found in system path, or a precompiled version supplied with this library)</td></tr>
60
- <tr><th>Performance</th><td>~40-120ms to convert a 40kb image (depending on *method* option)</td></tr>
61
- <tr><th>Reliability</th><td>No problems detected so far!</td></tr>
62
- <tr><th>Availability</th><td>According to ewww docs, requirements are met on surprisingly many webhosts. Look <a href="https://docs.ewww.io/article/43-supported-web-hosts">here</a> for a list</td></tr>
63
- <tr><th>General options supported</th><td>All (`quality`, `metadata`, `lossless`)</td></tr>
64
- <tr><th>Extra options</th><td>`method` (0-6)<br>`use-nice` (boolean)<br>`try-common-system-paths` (boolean)<br> `try-supplied-binary-for-os` (boolean)<br>`autofilter` (boolean)<br>`size-in-percentage` (number / null)<br>`command-line-options` (string)<br>`low-memory` (boolean)</td></tr>
65
- </table>
66
-
67
- [cwebp](https://developers.google.com/speed/webp/docs/cwebp) is a WebP conversion command line converter released by Google. Our implementation ships with precompiled binaries for Linux, FreeBSD, WinNT, Darwin and SunOS. If however a cwebp binary is found in a usual location, that binary will be preferred. It is executed with [exec()](http://php.net/manual/en/function.exec.php).
68
-
69
- In more detail, the implementation does this:
70
- - It is tested whether cwebp is available in a common system path (eg `/usr/bin/cwebp`, ..)
71
- - If not, then supplied binary is selected from `Converters/Binaries` (according to OS) - after validating checksum
72
- - Command-line options are generated from the options
73
- - If [`nice`]( https://en.wikipedia.org/wiki/Nice_(Unix)) command is found on host, binary is executed with low priority in order to save system resources
74
- - Permissions of the generated file are set to be the same as parent folder
75
-
76
- ### Cwebp options
77
-
78
- The following options are supported, besides the general options (such as quality, lossless etc):
79
-
80
- | Option | Type | Default |
81
- | -------------------------- | ------------------------- | -------------------------- |
82
- | autofilter | boolean | false |
83
- | command-line-options | string | '' |
84
- | low-memory | boolean | false |
85
- | method | integer (0-6) | 6 |
86
- | near-lossless | integer (0-100) | 60 |
87
- | size-in-percentage | integer (0-100) (or null) | null |
88
- | rel-path-to-precompiled-binaries | string | './Binaries' |
89
- | size-in-percentage | number (or null) | is_null |
90
- | try-common-system-paths | boolean | true |
91
- | try-supplied-binary-for-os | boolean | true |
92
- | use-nice | boolean | false |
93
-
94
- Descriptions (only of some of the options):
95
-
96
- #### the `autofilter` option
97
- Turns auto-filter on. This algorithm will spend additional time optimizing the filtering strength to reach a well-balanced quality. Unfortunately, it is extremely expensive in terms of computation. It takes about 5-10 times longer to do a conversion. A 1MB picture which perhaps typically takes about 2 seconds to convert, will takes about 15 seconds to convert with auto-filter. So in most cases, you will want to leave this at its default, which is off.
98
-
99
- #### the `command-line-options` option
100
- This allows you to set any parameter available for cwebp in the same way as you would do when executing *cwebp*. You could ie set it to "-sharpness 5 -mt -crop 10 10 40 40". Read more about all the available parameters in [the docs](https://developers.google.com/speed/webp/docs/cwebp)
101
-
102
- #### the `low-memory` option
103
- Reduce memory usage of lossy encoding at the cost of ~30% longer encoding time and marginally larger output size. Default: `false`. Read more in [the docs](https://developers.google.com/speed/webp/docs/cwebp). Default: *false*
104
-
105
- #### The `method` option
106
- This parameter controls the trade off between encoding speed and the compressed file size and quality. Possible values range from 0 to 6. 0 is fastest. 6 results in best quality.
107
-
108
- #### the `near-lossless` option
109
- Specify the level of near-lossless image preprocessing. This option adjusts pixel values to help compressibility, but has minimal impact on the visual quality. It triggers lossless compression mode automatically. The range is 0 (maximum preprocessing) to 100 (no preprocessing). The typical value is around 60. Read more [here](https://groups.google.com/a/webmproject.org/forum/#!topic/webp-discuss/0GmxDmlexek). Default: 60
110
-
111
- #### The `size-in-percentage` option
112
- This option sets the file size, *cwebp* should aim for, in percentage of the original. If you for example set it to *45*, and the source file is 100 kb, *cwebp* will try to create a file with size 45 kb (we use the `-size` option). This is an excellent alternative to the "quality:auto" option. If the quality detection isn't working on your system (and you do not have the rights to install imagick or gmagick), you should consider using this options instead. *Cwebp* is generally able to create webp files with the same quality at about 45% the size. So *45* would be a good choice. The option overrides the quality option. And note that it slows down the conversion - it takes about 2.5 times longer to do a conversion this way, than when quality is specified. Default is *off* (null)
113
-
114
-
115
- #### final words on cwebp
116
- The implementation is based on the work of Shane Bishop for his plugin, [EWWW Image Optimizer](https://ewww.io). Thanks for letting us do that!
117
-
118
- See [the wiki](https://github.com/rosell-dk/webp-convert/wiki/Installing-cwebp---using-official-precompilations) for instructions regarding installing cwebp or using official precompilations.
119
-
120
- ## vips
121
- <table>
122
- <tr><th>Requirements</th><td>Vips extension</td></tr>
123
- <tr><th>Performance</th><td>Great</td></tr>
124
- <tr><th>Reliability</th><td>No problems detected so far!</td></tr>
125
- <tr><th>Availability</th><td>Not that widespread yet, but gaining popularity</td></tr>
126
- <tr><th>General options supported</th><td>All (`quality`, `metadata`, `lossless`)</td></tr>
127
- <tr><th>Extra options</th><td>`smart-subsample`(boolean)<br>`alpha-quality`(0-100)<br>`near-lossless` (0-100)<br> `preset` (0-6)</td></tr>
128
- </table>
129
-
130
- For installation instructions, go [here](https://github.com/libvips/php-vips-ext).
131
-
132
- The options are described [here](https://jcupitt.github.io/libvips/API/current/VipsForeignSave.html#vips-webpsave)
133
-
134
- *near-lossless* is however an integer (0-100), in order to have the option behave like in cwebp.
135
-
136
-
137
-
138
- ## wpc
139
- *WebPConvert Cloud Service*
140
-
141
- <table>
142
- <tr><th>Requirements</th><td>Access to a server with [webp-convert-cloud-service](https://github.com/rosell-dk/webp-convert-cloud-service) installed, <code>cURL</code> and PHP >= 5.5.0</td></tr>
143
- <tr><th>Performance</th><td>Depends on the server where [webp-convert-cloud-service](https://github.com/rosell-dk/webp-convert-cloud-service) is set up, and the speed of internet connections. But perhaps ~1000ms to convert a 40kb image</td></tr>
144
- <tr><th>Reliability</th><td>Great (depends on the reliability on the server where it is set up)</td></tr>
145
- <tr><th>Availability</th><td>Should work on <em>almost</em> any webhost</td></tr>
146
- <tr><th>General options supported</th><td>All (`quality`, `metadata`, `lossless`)</td></tr>
147
- <tr><th>Extra options (old api)</th><td>`url`, `secret`</td></tr>
148
- <tr><th>Extra options (new api)</th><td>`url`, `api-version`, `api-key`, `crypt-api-key-in-transfer`</td></tr>
149
- </table>
150
-
151
- [wpc](https://github.com/rosell-dk/webp-convert-cloud-service) is an open source cloud service. You do not buy a key, you set it up on a server, or you set up [the Wordpress plugin](https://wordpress.org/plugins/webp-express/). As WebPConvert Cloud Service itself is based on WebPConvert, all options are supported.
152
-
153
- To use it, you need to set the `converter-options` (to add url etc).
154
-
155
- #### Example, where api-key is not crypted, on new API:
156
-
157
- ```php
158
- WebPConvert::convert($source, $destination, [
159
- 'max-quality' => 80,
160
- 'converters' => ['cwebp', 'wpc'],
161
- 'converter-options' => [
162
- 'wpc' => [
163
- 'api-version' => 1, /* from wpc release 1.0.0 */
164
- 'url' => 'http://example.com/wpc.php',
165
- 'api-key' => 'my dog is white',
166
- 'crypt-api-key-in-transfer' => false
167
- ]
168
- ]
169
- ));
170
- ```
171
-
172
- #### Example, where api-key is crypted:
173
-
174
- ```php
175
-
176
- WebPConvert::convert($source, $destination, [
177
- 'max-quality' => 80,
178
- 'converters' => ['cwebp', 'wpc'],
179
- 'converter-options' => [
180
- 'wpc' => [
181
- 'api-version' => 1,
182
- 'url' => 'https://example.com/wpc.php',
183
- 'api-key' => 'my dog is white',
184
- 'crypt-api-key-in-transfer' => true
185
- ],
186
- ]
187
- ));
188
- ```
189
-
190
- In 2.0, you can alternatively set the api key and urls through through the *WPC_API_KEY* and *WPC_API_URL* environment variables. This is a safer place to store it.
191
-
192
- To set an environment variable in Apache, you can use the `SetEnv` directory. Ie, place something like the following in your virtual host / or .htaccess file (replace the key with the one you purchased!)
193
-
194
- ```
195
- SetEnv WPC_API_KEY my-dog-is-dashed
196
- SetEnv WPC_API_URL https://wpc.example.com/wpc.php
197
- ```
198
-
199
-
200
- #### Example, old API:
201
-
202
- ```php
203
- WebPConvert::convert($source, $destination, [
204
- 'max-quality' => 80,
205
- 'converters' => ['cwebp', 'wpc'],
206
- 'converter-options' => [
207
- 'wpc' => [
208
- 'url' => 'https://example.com/wpc.php',
209
- 'secret' => 'my dog is white',
210
- ],
211
- ]
212
- ));
213
- ```
214
-
215
-
216
- ## ewww
217
-
218
- <table>
219
- <tr><th>Requirements</th><td>Valid EWWW Image Optimizer <a href="https://ewww.io/plans/">API key</a>, <code>cURL</code> and PHP >= 5.5.0</td></tr>
220
- <tr><th>Performance</th><td>~1300ms to convert a 40kb image</td></tr>
221
- <tr><th>Reliability</th><td>Great (but, as with any cloud service, there is a risk of downtime)</td></tr>
222
- <tr><th>Availability</th><td>Should work on <em>almost</em> any webhost</td></tr>
223
- <tr><th>General options supported</th><td>`quality`, `metadata` (partly)</td></tr>
224
- <tr><th>Extra options</th><td>`key`</td></tr>
225
- </table>
226
-
227
- EWWW Image Optimizer is a very cheap cloud service for optimizing images. After purchasing an API key, add the converter in the `extra-converters` option, with `key` set to the key. Be aware that the `key` should be stored safely to avoid exploitation - preferably in the environment, ie with [dotenv](https://github.com/vlucas/phpdotenv).
228
-
229
- The EWWW api doesn't support the `lossless` option, but it does automatically convert PNG's losslessly. Metadata is either all or none. If you have set it to something else than one of these, all metadata will be preserved.
230
-
231
- In more detail, the implementation does this:
232
- - Validates that there is a key, and that `curl` extension is working
233
- - Validates the key, using the [/verify/ endpoint](https://ewww.io/api/) (in order to [protect the EWWW service from unnecessary file uploads, when key has expired](https://github.com/rosell-dk/webp-convert/issues/38))
234
- - Converts, using the [/ endpoint](https://ewww.io/api/).
235
-
236
- <details>
237
- <summary><strong>Roadmap</strong> 👁</summary>
238
-
239
- The converter could be improved by using `fsockopen` when `cURL` is not available - which is extremely rare. PHP >= 5.5.0 is also widely available (PHP 5.4.0 reached end of life [more than two years ago!](http://php.net/supported-versions.php)).
240
- </details>
241
-
242
- #### Example:
243
-
244
- ```php
245
- WebPConvert::convert($source, $destination, [
246
- 'max-quality' => 80,
247
- 'converters' => ['gd', 'ewww'],
248
- 'converter-options' => [
249
- 'ewww' => [
250
- 'key' => 'your-api-key-here'
251
- ],
252
- ]
253
- ));
254
- ```
255
- In 2.0, you can alternatively set the api key by through the *EWWW_API_KEY* environment variable. This is a safer place to store it.
256
-
257
- To set an environment variable in Apache, you can use the `SetEnv` directory. Ie, place something like the following in your virtual host / or .htaccess file (replace the key with the one you purchased!)
258
-
259
- ```
260
- SetEnv EWWW_API_KEY sP3LyPpsKWZy8CVBTYegzEGN6VsKKKKA
261
- ```
262
-
263
- ## gd
264
-
265
- <table>
266
- <tr><th>Requirements</th><td>GD PHP extension and PHP >= 5.5.0 (compiled with WebP support)</td></tr>
267
- <tr><th>Performance</th><td>~30ms to convert a 40kb image</td></tr>
268
- <tr><th>Reliability</th><td>Not sure - I have experienced corrupted images, but cannot reproduce</td></tr>
269
- <tr><th>Availability</th><td>Unfortunately, according to <a href="https://stackoverflow.com/questions/25248382/how-to-create-a-webp-image-in-php">this link</a>, WebP support on shared hosts is rare.</td></tr>
270
- <tr><th>General options supported</th><td>`quality`</td></tr>
271
- <tr><th>Extra options</th><td>`skip-pngs`</td></tr>
272
- </table>
273
-
274
- [imagewebp](http://php.net/manual/en/function.imagewebp.php) is a function that comes with PHP (>5.5.0), *provided* that PHP has been compiled with WebP support.
275
-
276
- `gd` neither supports copying metadata nor exposes any WebP options. Lacking the option to set lossless encoding results in poor encoding of PNGs - the filesize is generally much larger than the original. For this reason, PNG conversion is *disabled* by default, but it can be enabled my setting `skip-pngs` option to `false`.
277
-
278
- Installaition instructions are [available in the wiki](https://github.com/rosell-dk/webp-convert/wiki/Installing-Gd-extension).
279
-
280
- <details>
281
- <summary><strong>Known bugs</strong> 👁</summary>
282
- Due to a [bug](https://bugs.php.net/bug.php?id=66590), some versions sometimes created corrupted images. That bug can however easily be fixed in PHP (fix was released [here](https://stackoverflow.com/questions/30078090/imagewebp-php-creates-corrupted-webp-files)). However, I have experienced corrupted images *anyway* (but cannot reproduce that bug). So use this converter with caution. The corrupted images look completely transparent in Google Chrome, but have the correct size.
283
- </details>
284
-
285
- ## imagick
286
-
287
- <table>
288
- <tr><th>Requirements</th><td>Imagick PHP extension (compiled with WebP support)</td></tr>
289
- <tr><th>Quality</th><td>Poor. [See this issue]( https://github.com/rosell-dk/webp-convert/issues/43)</td></tr>
290
- <tr><th>General options supported</th><td>`quality`</td></tr>
291
- <tr><th>Extra options</th><td>None</td></tr>
292
- <tr><th>Performance</th><td>~20-320ms to convert a 40kb image</td></tr>
293
- <tr><th>Reliability</th><td>No problems detected so far</td></tr>
294
- <tr><th>Availability</th><td>Probably only available on few shared hosts (if any)</td></tr>
295
- </table>
296
-
297
- WebP conversion with `imagick` is fast and [exposes many WebP options](http://www.imagemagick.org/script/webp.php). Unfortunately, WebP support for the `imagick` extension is pretty uncommon. At least not on the systems I have tried (Ubuntu 16.04 and Ubuntu 17.04). But if installed, it works great and has several WebP options.
298
-
299
- See [this page](https://github.com/rosell-dk/webp-convert/wiki/Installing-Imagick-extension) in the Wiki for instructions on installing the extension.
300
-
301
- ## imagickbinary
302
- <table>
303
- <tr><th>Requirements</th><td><code>exec()</code> function and that imagick is installed on webserver, compiled with webp support</td></tr>
304
- <tr><th>Performance</th><td>just fine</td></tr>
305
- <tr><th>Reliability</th><td>No problems detected so far!</td></tr>
306
- <tr><th>Availability</th><td>Not sure</td></tr>
307
- <tr><th>General options supported</th><td>`quality`</td></tr>
308
- <tr><th>Extra options</th><td>`use-nice` (boolean)</td></tr>
309
- </table>
310
-
311
- This converter tryes to execute `convert source.jpg webp:destination.jpg.webp`.
312
-
313
- ## stack
314
-
315
- <table>
316
- <tr><th>General options supported</th><td>all (passed to the converters in the stack )</td></tr>
317
- <tr><th>Extra options</th><td>`converters` (array) and `converter-options` (array)</td></tr>
318
- </table>
319
-
320
- Stack implements the functionality you know from `WebPConvert::convert`. In fact, all `WebPConvert::convert` does is to call `Stack::convert($source, $destination, $options, $logger);`
321
-
322
- It has two special options: `converters` and `converter-options`. You can read about those in `docs/api/convert.md`
vendor/rosell-dk/webp-convert/docs/v1.3/serving/convert-and-serve.md DELETED
@@ -1,167 +0,0 @@
1
- # API: The WebPConvert::convertAndServe() method
2
-
3
- *NOTE:* In 2.0, the method is renamed to *serveConverted* ("convertAndServe" was implying that a conversion was always made, but the method simply serves destination if it exists and is smaller and newer than source)
4
-
5
- The method tries to serve a converted image. If destination already exists, the already converted image will be served. Unless the original is newer or smaller. If the method fails, it will serve original image, a 404, or whatever the 'fail' option is set to.
6
-
7
- **WebPConvert::convertAndServe($source, $destination, $options)**
8
-
9
- | Parameter | Type | Description |
10
- | ---------------- | ------- | ------------------------------------------------------------------- |
11
- | `$source` | String | Absolute path to source image (only forward slashes allowed) |
12
- | `$destination` | String | Absolute path to converted image (only forward slashes allowed) |
13
- | `$options` | Array | Array of options (see below) |
14
-
15
- ## The *$options* argument
16
- The options argument is a named array. Besides the options described below, you can also use any options that the *convert* method takes (if a fresh convertion needs to be created, this method will call the *convert* method and hand over the options argument)
17
-
18
- ### *convert*
19
- Conversion options, handed over to the convert method, in case a conversion needs to be made. The convert options are documented [here](https://github.com/rosell-dk/webp-convert/blob/master/docs/v2.0/converting/options.md).
20
-
21
- ### *fail*
22
- Indicate what to do, in case of normal conversion failure.
23
- Default value: *"original"*
24
-
25
- | Possible values | Meaning |
26
- | ----------------- | ----------------------------------------------- |
27
- | "serve-original" | Serve the original image. |
28
- | "404" | Serve 404 status (not found) |
29
- | "report-as-image" | Serve an image with text explaining the problem |
30
- | "report" | Serve a textual report explaining the problem |
31
-
32
- ### *fail-when-original-unavailable*
33
- Possible values: Same as above, except that "original" is not an option.
34
- Default value: *"404"*
35
-
36
- ### *show-report*
37
- Produce a report rather than serve an image.
38
- Default value: *false*
39
-
40
- ### *reconvert*
41
- Force a conversion, discarding existing converted image (if any).
42
- Default value: *false*
43
-
44
- ### *serve-original*
45
- Forces serving original image. This will skip conversion.
46
- Default value: *false*
47
-
48
- ### *add-x-header-status*
49
- When set to *true*, a *X-WebP-Convert-Status* header will be added describing how things went.
50
- Default value: *true*
51
-
52
- Depending on how things goes, the header will be set to one of the following:
53
- - "Failed (missing source argument)"
54
- - "Failed (source not found)""
55
- - "Failed (missing destination argument)"
56
- - "Reporting..."
57
- - "Serving original image (was explicitly told to)"
58
- - "Serving original image - because it is smaller than the converted!"
59
- - "Serving freshly converted image (the original had changed)"
60
- - "Serving existing converted image"
61
- - "Converting image (handed over to WebPConvertAndServe)"
62
- - "Serving freshly converted image"
63
- - "Failed (could not convert image)"
64
-
65
- ### *add-vary-header*
66
- Add a "Vary: Accept" header when an image is served. Experimental.
67
- Default value: *true*
68
-
69
- ### *add-content-type-header*
70
- Add a "Content-Type" header
71
- Default value: *true*
72
- If set, a *Content-Type* header will be added. It will be set to "image/webp" if a converted image is served, "image/jpeg" or "image/png", if the original is served or "image/gif", if an error message is served (as image). You can set it to false when debugging (to check if any errors are being outputted)
73
-
74
- ### *add-last-modified-header*
75
- Add a "Last-Modified" header
76
- Default value: *true*
77
- If set, a *Last-Modified* header will be added. When a cached image is served, it will be set to the modified time of the converted file. When a fresh image is served, it is set to current time.
78
-
79
- ### *cache-control-header*
80
- Specify a cache control header, which will be served when caching is appropriate.
81
- Default value: "public, max-age=86400" (1 day)
82
- Caching is "deemed appropriate", when destination is served, source is served, because it is lighter or a fresh conversion is made, due to there not being any converted image at the destination yet. Caching is not deemed appropriate when something fails, a report is requested, or the *reconvert* option have been set. Note: in version 1.3.2 and below, the *serve-original* option also prevented caching, but it no longer does. previous In those cases, standard headers will be used for preventing caching.
83
- For your convenience, here is a little table:
84
-
85
- | duration | max-age |
86
- | -------- | ---------------- |
87
- | 1 second | max-age=1 |
88
- | 1 minute | max-age=60 |
89
- | 1 hour | max-age=3600 |
90
- | 1 day | max-age=86400 |
91
- | 1 week | max-age=604800 |
92
- | 1 month | max-age=2592000 |
93
- | 1 year | max-age=31536000 |
94
-
95
- To learn about the options for the Cache-Control header, go [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control)
96
-
97
- ### *error-reporting*
98
- Set error reporting
99
- Allowed values: *"auto"*, *"dont-mess"*, *true*, *false*
100
- Default value: *"auto"*
101
-
102
- If set to true, error reporting will be turned on, like this:
103
- ```
104
- error_reporting(E_ALL);
105
- ini_set('display_errors', 'On');
106
- ```
107
-
108
- If set to false, error reporting will be turned off, like this:
109
- ```
110
- error_reporting(0);
111
- ini_set('display_errors', 'Off');
112
- ```
113
- If set to "auto", errors will be turned off, unless the `show-report` option is set, in which case errors will be turned off.
114
- If set to "dont-mess", error reporting will not be touched.
115
-
116
- ### *aboutToServeImageCallBack*
117
- This callback is called right before response headers and image is served. This is a great chance to adding headers. You can stop the image and the headers from being served by returning *false*.
118
-
119
- **Arguments:**
120
- The first argument to the callback contains a string that tells what is about to be served. It can be 'fresh-conversion', 'destination' or 'source'.
121
-
122
- The second argument tells you why that is served. It can be one of the following:
123
- for 'source':
124
- - "explicitly-told-to" (when the "serve-original" option is set)
125
- - "source-lighter" (when original image is actually smaller than the converted)
126
-
127
- for 'fresh-conversion':
128
- - "explicitly-told-to" (when the "reconvert" option is set)
129
- - "source-modified" (when source is newer than existing)
130
- - "no-existing" (when there is no existing at the destination)
131
-
132
- for 'destination':
133
- - "no-reason-not-to" (it is lighter than source, its not older, and we were not told to do otherwise)
134
-
135
- Example of callback:
136
- ```
137
- function aboutToServeImageCallBack($servingWhat, $whyServingThis, $obj)
138
- {
139
- echo 'about to serve: ' . $servingWhat . '<br>';
140
- echo 'Why? - because: ' . $whyServingThis;
141
- return false; // Do not serve! (this also prevents any response headers from being added)
142
- }
143
- ```
144
-
145
- ### *aboutToPerformFailActionCallback*
146
- This callback is called right before doing the action specified in the `fail` option, or the `fail-when-original-unavailable` option. You can stop the fail action from being executod by returning *false*.
147
-
148
- Documentation by example:
149
- ```
150
- function aboutToPerformFailActionCallback($errorTitle, $errorDescription, $actionAboutToBeTaken, $serveConvertedObj)
151
- {
152
- echo '<h1>' . $errorTitle . '</h1>';
153
- echo $errorDescription;
154
- if (actionAboutToBeTaken == '404') {
155
- // handle 404 differently than webp-convert would
156
- $protocol = isset($_SERVER["SERVER_PROTOCOL"]) ? $_SERVER["SERVER_PROTOCOL"] : 'HTTP/1.0';
157
- $serveConvertedObj->header($protocol . " 404 Not Found. We take this very seriously. Heads will roll.");
158
-
159
- return false; // stop webp-convert from doing what it would do
160
- }
161
-
162
- }
163
- ```
164
-
165
- ### *require-for-conversion*
166
- If set, makes the library 'require in' a file just before doing an actual conversion with `ConvertAndServe::convertAndServe()`. This is not needed for composer projects, as composer takes care of autoloading classes when needed.
167
- Default value: *null*
vendor/rosell-dk/webp-convert/docs/v1.3/webp-on-demand/tweaks.md DELETED
@@ -1,167 +0,0 @@
1
- # Tweaks
2
-
3
- ## Store converted images in separate folder
4
-
5
- In most cases, you probably want the cache of converted images to be stored in their own folder rather than have them mingled with the source files.
6
-
7
- To have have the cache folder contain a file structure mirroring the structure of the original files, you can do this:
8
-
9
- ```php
10
- $applicationRoot = $_SERVER["DOCUMENT_ROOT"]; // If your application is not in document root, you can change accordingly.
11
- $imageRoot = $applicationRoot . '/webp-images'; // Change to where you want the webp images to be saved
12
- $sourceRel = substr($source, strlen($applicationRoot));
13
- $destination = $imageRoot . $sourceRel . '.webp';
14
- ```
15
-
16
- If your images are stored outside document root (a rare case), you can simply use the complete absolute path:
17
- ```php
18
- $destination = $imageRoot . $source . '.webp'; // pst: $source is an absolute path, and starts with '/'
19
- ```
20
- This will ie store a converted image in */var/www/example.com/public_html/app/webp-images/var/www/example.com/images/logo.jpg.webp*
21
-
22
- If your application can be configured to store outside document root, but rarely is, you can go for this structure:
23
-
24
- ```php
25
- $docRoot = $_SERVER["DOCUMENT_ROOT"];
26
- $imageRoot = $contentDirAbs . '/webp-images';
27
-
28
- if (substr($source, 0, strlen($docRoot)) === $docRoot) {
29
- // Source file is residing inside document root.
30
- // We can store relative to that.
31
- $sourceRel = substr($source, strlen($docRoot));
32
- $destination = $imageRoot . '/doc-root' . $sourceRel . '.webp';
33
- } else {
34
- // Source file is residing outside document root.
35
- // we must add complete path to structure
36
- $destination = $imageRoot . '/abs' . $source . '.webp';
37
- }
38
- ```
39
-
40
- If you do not know the application root beforehand, and thus do not know the appropriate root for the converted images, see next tweak.
41
-
42
-
43
- ## Get the application root automatically
44
- When you want destination files to be put in their own folder, you need to know the root of the application (the folder in which the .htaccess rules resides). In most applications, you know the root. In many cases, it is simply the document root. However, if you are writing an extension, plugin or module to a framework that can be installed in a subfolder, you may have trouble finding it. Many applications have a *index.php* in the root, which can get it with `__DIR__`. However, you do not want to run an entire bootstrap each time you serve an image. Obviously, to get around this, you can place *webp-on-demand.php* in the webroot. However, some frameworks, such as Wordpress, will not allow a plugin to put a file in the root. Now, how could we determine the application root from a file inside some subdir? Here are three suggestions:
45
-
46
- 1. You could traverse parent folders until you find a file you expect to be in application root (ie a .htaccess containing the string "webp-on-demand.php"). This should work.
47
- 2. If the rules in the *.htaccess* file are generated by your application, you probably have access to the path at generation time. You can then simply put the path in the *.htaccess*, as an extra parameter to the script (or better: the relative path from document root to the application).
48
- 3. You can use the following hack:
49
-
50
- ### The hack
51
- The idea is to grab the URL path of the image in the *.htaccess* and pass it to the script. Assuming that the URL paths always matches the file paths, we can get the application root by subtracting that relative path to source from the absolute path to source.
52
-
53
- In *.htaccess*, we grab the url-path by appending "&url-path=$1.$2" to the rewrite rule:
54
- ```
55
- RewriteRule ^(.*)\.(jpe?g|png)$ webp-on-demand.php?source=%{SCRIPT_FILENAME}&url-path=$1.$2 [NC,L]
56
- ```
57
-
58
- In the script, we can then calculate the application root like this:
59
-
60
- ```php
61
- $applicationRoot = substr($_GET['source'], 0, -strlen($_GET['url-path']));
62
- ```
63
-
64
- ## CDN
65
- To work properly with a CDN, a "Vary Accept" header should be added when serving images. This is a declaration that the response varies with the *Accept* header (recall that we inspect *Accept* header in the .htaccess to determine if the browsers supports webp images). If this header is missing, the CDN will see no reason to cache separate images depending on the Accept header.
66
-
67
- Add this snippet to the *.htaccess* to make webp-on-demand work with CDN's:
68
-
69
- ```
70
- <IfModule mod_headers.c>
71
- SetEnvIf Request_URI "\.(jpe?g|png)" ADDVARY
72
-
73
- # Declare that the response varies depending on the accept header.
74
- # The purpose is to make CDN cache both original images and converted images.
75
- Header append "Vary" "Accept" env=ADDVARY
76
- </IfModule>
77
- ```
78
-
79
- ***Note:*** When configuring the CDN, you must make sure to set it up to forward the the "Accept" header to your origin server.
80
-
81
-
82
-
83
- ## Make .htaccess route directly to existing images
84
-
85
- There may be a performance benefit of using the *.htaccess* file to route to already converted images, instead of letting the PHP script serve it. Note however:
86
- - If you do the routing in .htaccess, the solution will not be able to discard converted images when original images are updated.
87
- - Performance benefit may be insignificant (*WebPConvertAndServe* class is not autoloaded when serving existing images)
88
-
89
- Add the following to the *.htaccess* to make it route to existing converted images. Place it above the # Redirect images to webp-on-demand.php" comment. Take care of replacing [[your-base-path]] with the directory your *.htaccess* lives in (relative to document root, and [[your-destination-root]] with the directory the converted images resides.
90
- ```
91
- # Redirect to existing converted image (under appropriate circumstances)
92
- RewriteCond %{HTTP_ACCEPT} image/webp
93
- RewriteCond %{DOCUMENT_ROOT}/[[your-base-path]]/[[your-destination-root]]/$1.$2.webp -f
94
- RewriteRule ^\/?(.*)\.(jpe?g|png)$ /[[your-base-path]]/[[your-destination-root]]/$1.$2.webp [NC,T=image/webp,L]
95
- ```
96
- *edit:* Removed the QSD flag from the RewriteRule because it is not supported in Apache < 2.4 (and it [triggers error](https://github.com/rosell-dk/webp-express/issues/155))
97
-
98
- ### Redirect with CDN support
99
- If you are using a CDN, and want to redirect to existing images with the .htaccess, it is a good idea to add a "Vary Accept" header. This instructs the CDN that the response varies with the *Accept* header (we do not need to do that when routing to webp-on-demand.php, because the script takes care of adding this header, when appropriate.)
100
-
101
- You can achieve redirect with CDN support with the following rules:
102
- ```
103
- <IfModule mod_rewrite.c>
104
-
105
- RewriteEngine On
106
-
107
- # Redirect to existing converted image (under appropriate circumstances)
108
- RewriteCond %{HTTP_ACCEPT} image/webp
109
- RewriteCond %{DOCUMENT_ROOT}/[[your-base-path]]/[[your-destination-root]]/$1.$2.webp -f
110
- RewriteRule ^\/?(.*)\.(jpe?g|png)$ /[[your-base-path]]/[[your-destination-root]]/$1.$2.webp [NC,T=image/webp,QSD,E=WEBPACCEPT:1,L]
111
-
112
- # Redirect images to webp-on-demand.php (if browser supports webp)
113
- RewriteCond %{HTTP_ACCEPT} image/webp
114
- RewriteRule ^(.*)\.(jpe?g|png)$ webp-on-demand.php?source=%{SCRIPT_FILENAME}&url-path=$1.$2 [NC,L]
115
-
116
- </IfModule>
117
-
118
- <IfModule mod_headers.c>
119
- # Apache appends "REDIRECT_" in front of the environment variables, but LiteSpeed does not.
120
- # These next line is for Apache, in order to set environment variables without "REDIRECT_"
121
- SetEnvIf REDIRECT_WEBPACCEPT 1 WEBPACCEPT=1
122
-
123
- # Make CDN caching possible.
124
- # The effect is that the CDN will cache both the webp image and the jpeg/png image and return the proper
125
- # image to the proper clients (for this to work, make sure to set up CDN to forward the "Accept" header)
126
- Header append Vary Accept env=WEBPACCEPT
127
- </IfModule>
128
-
129
- AddType image/webp .webp
130
- ```
131
-
132
- ## Forward the querystring
133
- By forwarding the query string, you can allow control directly from the URL. You could for example make it possible to add "?debug" to an image URL, and thereby getting a conversion report. Or make "?reconvert" force reconversion.
134
-
135
- In order to forward the query string, you need to add this condition before the RewriteRule that redirects to *webp-on-demand.php*:
136
- ```
137
- RewriteCond %{QUERY_STRING} (.*)
138
- ```
139
- That condition will always be met. The side effect is that it stores the match (the complete querystring). That match will be available as %1 in the RewriteRule. So, in the RewriteRule, we will have to add "&%1" after the last argument. Here is a complete solution:
140
- ```
141
- <IfModule mod_rewrite.c>
142
- RewriteEngine On
143
-
144
- # Redirect images to webp-on-demand.php (if browser supports webp)
145
- RewriteCond %{HTTP_ACCEPT} image/webp
146
- RewriteCond %{QUERY_STRING} (.*)
147
- RewriteRule ^(.*)\.(jpe?g|png)$ webp-on-demand.php?source=%{SCRIPT_FILENAME}&%1 [NC,L]
148
- </IfModule>
149
-
150
- AddType image/webp .webp
151
- ```
152
-
153
- Of course, in order to *do* something with that querystring, you must use them in your *webp-on-demand.php* script. You could for example use them directly in the options array sent to the *convertAndServe()* method. To achieve the mentioned "debug" and "reconvert" features, do this:
154
- ```php
155
- $options = [
156
- 'show-report' => isset($_GET['debug']),
157
- 'reconvert' => isset($_GET['reconvert']),
158
- 'serve-original' => isset($_GET['original']),
159
- ];
160
- ```
161
-
162
- *EDIT:*
163
- I have just discovered a simpler way to achieve the querystring forward: The [QSA flag](https://httpd.apache.org/docs/trunk/rewrite/flags.html).
164
- So, simply set the QSA flag in the RewriteRule, and nothing more:
165
- ```
166
- RewriteRule ^(.*)\.(jpe?g|png)$ webp-on-demand.php?source=%{SCRIPT_FILENAME} [NC,QSA,L]
167
- ```
vendor/rosell-dk/webp-convert/docs/v1.3/webp-on-demand/webp-on-demand.md DELETED
@@ -1,133 +0,0 @@
1
- # WebP on demand
2
-
3
- This is a solution for automatically serving WebP images instead of jpeg/pngs [for browsers that supports WebP](https://caniuse.com/#feat=webp) (At the time of writing, 78% of all mobile users and 72% of all desktop users uses browsers supporting webp)
4
-
5
- Once set up, it will automatically convert images, no matter how they are referenced. It for example also works on images referenced in CSS. As the solution does not require any change in the HTML, it can easily be integrated into any website / framework
6
-
7
- ## Overview
8
-
9
- A setup consists of a PHP script that serves converted images and some *redirect rules* that redirects JPG/PNG images to the script.
10
-
11
-
12
- ## Requirements
13
-
14
- * *Apache* or *LiteSpeed* web server. Can be made to work with *NGINX* as well. Documentation is on the roadmap.
15
- * *mod_rewrite* module for Apache
16
- * PHP >= 5.6 (we are only testing down to 5.6. It should however work in 5.5 as well)
17
- * That one of the *webp-convert* converters are working (these have different requirements)
18
-
19
- ## Installation
20
-
21
- Here we assume you are using Composer. [Not using composer? - Follow me!](https://github.com/rosell-dk/webp-convert/blob/master/docs/v1.3/webp-on-demand/without-composer.md)
22
-
23
- ### 1. Require the webp-convert library with composer
24
- ```
25
- composer require rosell-dk/webp-convert
26
- ```
27
-
28
-
29
- ### 2. Create the script
30
-
31
- Create a file *webp-on-demand.php*, and place it in webroot, or where-ever you like in you web-application.
32
-
33
- Here is a minimal example to get started with:
34
-
35
- ```php
36
- <?php
37
- require 'vendor/autoload.php'; // Make sure to point this correctly
38
-
39
- use WebPConvert\WebPConvert;
40
-
41
- $source = $_GET['source']; // Absolute file path to source file. Comes from the .htaccess
42
- $destination = $source . '.webp'; // Store the converted images besides the original images (other options are available!)
43
-
44
- $options = [
45
-
46
- // UNCOMMENT NEXT LINE, WHEN YOU ARE UP AND RUNNING!
47
- 'show-report' => true // Show a conversion report instead of serving the converted image.
48
-
49
- // More options available!
50
- ];
51
- WebPConvert::convertAndServe($source, $destination, $options);
52
- ```
53
-
54
- ### 3. Add redirect rules
55
- Place the following rewrite rules in a *.htaccess* file in the directory where you want the solution to take effect:
56
-
57
- ```
58
- <IfModule mod_rewrite.c>
59
- RewriteEngine On
60
-
61
- # Redirect images to webp-on-demand.php (if browser supports webp)
62
- RewriteCond %{HTTP_ACCEPT} image/webp
63
- RewriteCond %{REQUEST_FILENAME} -f
64
- RewriteRule ^(.*)\.(jpe?g|png)$ webp-on-demand.php?source=%{SCRIPT_FILENAME} [NC,L]
65
- </IfModule>
66
-
67
- AddType image/webp .webp
68
- ```
69
- If you have placed *webp-on-demand.php* in a subfolder, you will need to change the rewrite rule accordingly.
70
-
71
- The `RewriteCond %{REQUEST_FILENAME} -f` is not strictly necessary, but there to be sure that we got an existing file, and it could perhaps also prevent some undiscovered way of misuse.
72
-
73
- ### 4. Validate that it works
74
-
75
- Browse to a JPEG image. Instead of an image, you should see a conversion report. Hopefully, you get a success. Otherwise, you need to hook up to a cloud converter or try to meet the requirements for cwebp, gd or imagick.
76
-
77
- Once you get a successful conversion, you can uncomment the "show-report" option in the script.
78
-
79
- It should work now, but to be absolute sure:
80
-
81
- - Visit a page on your site with an image on it, using *Google Chrome*.
82
- - Right-click the page and choose "Inspect"
83
- - Click the "Network" tab
84
- - Reload the page
85
- - Find a jpeg or png image in the list. In the "type" column, it should say "webp". There should also be a *X-WebP-Convert-Status* header on the image that provides some insights on how things went.
86
-
87
-
88
- ### 5. Try this improvement and see if it works
89
-
90
- It seems that it is not necessary to pass the filename in the query string.
91
-
92
- Try replacing `$source = $_GET['source'];` in the script with the following:
93
-
94
- ```php
95
- $docRoot = rtrim($_SERVER["DOCUMENT_ROOT"], '/');
96
- $requestUriNoQS = explode('?', $_SERVER['REQUEST_URI'])[0];
97
- $source = $docRoot . urldecode($requestUriNoQS);
98
- ```
99
-
100
- And you can then remove `?source=%{SCRIPT_FILENAME}` from the `.htaccess` file.
101
-
102
- There are some benefits of not passing in query string:
103
- 1. Passing a path in the query string may be blocked by a firewall, as it looks suspicious.
104
- 2. The script called to convert arbitrary files
105
- 3. One person experienced problems with spaces in filenames passed in the query string. See [this issue](https://github.com/rosell-dk/webp-convert/issues/95)
106
-
107
-
108
- ### 6. Customizing and tweaking
109
-
110
- Basic customizing is done by setting options in the `$options` array. Check out the [docs on convert()](https://github.com/rosell-dk/webp-convert/blob/master/docs/v1.3/converting/convert.md) and the [docs on convertAndServe()](https://github.com/rosell-dk/webp-convert/blob/master/docs/v1.3/serving/convert-and-serve.md)
111
-
112
- Other tweaking is described in *docs/webp-on-demand/tweaks.md*:
113
- - [Store converted images in separate folder](https://github.com/rosell-dk/webp-convert/blob/master/docs/v1.3/webp-on-demand/tweaks.md#store-converted-images-in-separate-folder)
114
- - [CDN](https://github.com/rosell-dk/webp-convert/blob/master/docs/v1.3/webp-on-demand/tweaks.md#cdn)
115
- - [Make .htaccess route directly to existing images](https://github.com/rosell-dk/webp-convert/blob/master/docs/v1.3/webp-on-demand/tweaks.md#make-htaccess-route-directly-to-existing-images)
116
- - [Forward the query string](https://github.com/rosell-dk/webp-convert/blob/master/docs/v1.3/webp-on-demand/tweaks.md#forward-the-querystring)
117
-
118
-
119
- ## Troubleshooting
120
-
121
- ### The redirect rule doesn't seem to be working
122
- If images are neither routed to the converter or a 404, it means that the redirect rule isn't taking effect. Common reasons for this includes:
123
-
124
- - Perhaps there are other rules in your *.htaccess* that interfere with the rules?
125
- - Perhaps your site is on *Apache*, but it has been configured to use *Nginx* to serve image files. To find out which server that is handling the images, browse to an image and eximine the "Server" response header. In case *NGINX* are serving images, see if you can reconfigure your server setup. Alternatively, you can create *NGINX* rewrite rules. There are some [here](https://github.com/S1SYPHOS/kirby-webp#nginx) and [there](https://github.com/uhop/grunt-tight-sprite/wiki/Recipe:-serve-WebP-with-nginx-conditionally).
126
- - Perhaps the server isn't configured to allow *.htaccess* files? Try inserting rubbish in the top of the *.htaccess* file and refresh. You should now see an *Internal Server Error* error page. If you don't, your *.htaccess* file is ignored. Probably you will need to set *AllowOverride All* in your Virtual Host. [Look here for more help](
127
- https://docs.bolt.cm/3.4/howto/making-sure-htaccess-works#test-if-htaccess-is-working)
128
- - Perhaps the Apache *mod_rewrite* extension isn't enabled? Try removing both `<IfModule mod_rewrite.c>` and `</IfModule>` lines: if you get an *Internal Server Error* error page after this change, it's probably that it's indeed not enabled.
129
-
130
-
131
- ## Related
132
- * https://www.maxcdn.com/blog/how-to-reduce-image-size-with-webp-automagically/
133
- * https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website
vendor/rosell-dk/webp-convert/docs/v1.3/webp-on-demand/without-composer.md DELETED
@@ -1,45 +0,0 @@
1
- # WebP On Demand without composer
2
-
3
- For your convenience, the library has been cooked down to two files: *webp-on-demand-1.inc* and *webp-on-demand-2.inc*. The second one is loaded when the first one decides it needs to do a conversion (and not simply serve existing image).
4
-
5
- ## Installing
6
-
7
- ### 1. Copy the latest build files into your website
8
- Copy *webp-on-demand-1.inc* and *webp-on-demand-2.inc* from the *build* folder into your website (in 2.0, they are located in "src-build"). They can be located wherever you like.
9
-
10
- ### 2. Create a *webp-on-demand.php*
11
-
12
- Create a file *webp-on-demand.php*, and place it in webroot, or where-ever you like in you web-application.
13
-
14
- Here is a minimal example to get started with. Note that this example only works in version 1.x. In 2.0, the `require-for-conversion` option has been removed, so the [procedure is different](https://github.com/rosell-dk/webp-convert/blob/master/docs/v2.0/webp-on-demand/without-composer.md).
15
-
16
- ```php
17
- <?php
18
- // To start with, lets display any errors.
19
- // You can later comment these out
20
- error_reporting(E_ALL);
21
- ini_set("display_errors", 1);
22
-
23
- require 'webp-on-demand-1.inc';
24
-
25
- use WebPConvert\WebPConvert;
26
-
27
- $source = $_GET['source']; // Absolute file path to source file. Comes from the .htaccess
28
- $destination = $source . '.webp'; // Store the converted images besides the original images (other options are available!)
29
-
30
- $options = [
31
-
32