WebP Express - Version 0.14.2

Version Description

(released: 17 jun 2019)

  • Fixed problem with older versions of cwebp
  • Fixed that images was not deleted
  • Fixed cache problem on options page on systems that disables cache busting (it resulted in "SyntaxError: JSON.parse")
Download this release

Release Info

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

Code changes from version 0.14.1 to 0.14.2

Files changed (46) hide show
  1. README.md +9 -0
  2. README.txt +13 -3
  3. composer.json +1 -1
  4. composer.lock +6 -6
  5. lib/alter-html.php +2 -0
  6. lib/classes/AdminInit.php +29 -19
  7. lib/classes/HandleDeleteFileHook.php +2 -2
  8. lib/debug.php +1 -0
  9. lib/options/enqueue_scripts.php +17 -15
  10. lib/options/js/{authorized_sites_bak.js → 0.14.2/authorized_sites_bak.js} +0 -0
  11. lib/options/js/{bulk-convert.js → 0.14.2/bulk-convert.js} +0 -0
  12. lib/options/js/{converters.js → 0.14.2/converters.js} +0 -0
  13. lib/options/js/{das-popup.js → 0.14.2/das-popup.js} +0 -0
  14. lib/options/js/{image-comparison-slider.js → 0.14.2/image-comparison-slider.js} +0 -0
  15. lib/options/js/{page.js → 0.14.2/page.js} +0 -0
  16. lib/options/js/{purge-cache.js → 0.14.2/purge-cache.js} +0 -0
  17. lib/options/js/{sortable.min.js → 0.14.2/sortable.min.js} +0 -0
  18. lib/options/js/{test-convert.js → 0.14.2/test-convert.js} +0 -0
  19. lib/options/js/{whitelist.js → 0.14.2/whitelist.js} +0 -0
  20. lib/options/js/{whitelist_old.js → 0.14.2/whitelist_old.js} +0 -0
  21. lib/options/page-messages.php +2 -0
  22. lib/options/page-welcome.php +2 -0
  23. lib/options/page.php +2 -0
  24. lib/options/submit.php +2 -0
  25. lib/wpc.php +0 -266
  26. vendor/composer/autoload_classmap.php +78 -0
  27. vendor/composer/autoload_static.php +82 -0
  28. vendor/composer/installed.json +6 -6
  29. vendor/rosell-dk/webp-convert/docs/v2.0/converting/introduction-for-converting.md +7 -3
  30. vendor/rosell-dk/webp-convert/src-build/webp-convert.inc +268 -199
  31. vendor/rosell-dk/webp-convert/src-build/webp-on-demand-2.inc +268 -199
  32. vendor/rosell-dk/webp-convert/src/Convert/Converters/AbstractConverter.php +3 -1
  33. vendor/rosell-dk/webp-convert/src/Convert/Converters/Binaries/cwebp-linux +0 -0
  34. vendor/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/EncodingAutoTrait.php +2 -0
  35. vendor/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php +234 -174
  36. vendor/rosell-dk/webp-convert/src/Convert/Converters/Ewww.php +5 -2
  37. vendor/rosell-dk/webp-convert/src/Convert/Converters/GraphicsMagick.php +6 -4
  38. vendor/rosell-dk/webp-convert/src/Convert/Converters/ImageMagick.php +6 -9
  39. vendor/rosell-dk/webp-convert/src/Convert/Converters/Stack.php +2 -2
  40. vendor/rosell-dk/webp-convert/src/Convert/Converters/Wpc.php +10 -4
  41. vendor/rosell-dk/webp-convert/src/Serve/Report.php +0 -3
  42. vendor/rosell-dk/webp-convert/tests/Convert/Converters/EwwwTest.php +2 -2
  43. vendor/rosell-dk/webp-convert/tests/Convert/Converters/WPCTest.php +12 -12
  44. vendor/rosell-dk/webp-convert/tests/Convert/Exposers/CwebpExposer.php +2 -2
  45. web-service/wpc.php +0 -1
  46. webp-express.php +3 -1
README.md CHANGED
@@ -597,6 +597,15 @@ Here are my current plans ahead: 0.15 will probably be a file manager-like inter
597
598
If you wish to affect priorities, it is certainly possible. You can try to argue your case in the forum or you can simply let the money do the talking. By donating as little as a cup of coffee on [ko-fi.com/rosell](https://ko-fi.com/rosell), you can leave a wish. I shall take these wishes into account when prioritizing between new features.
599
600
## Changes in 0.14.0
601
- Added new "encoding" option, which can be set to auto. This can in some cases dramatically reduce the size of the webp. It is supported by all converters except ewww and gd.
602
- Added new "near-lossless" option (only for cwebp and vips). Using this is a good idea for reducing size of lossless webps with an acceptable loss of quality
597
598
If you wish to affect priorities, it is certainly possible. You can try to argue your case in the forum or you can simply let the money do the talking. By donating as little as a cup of coffee on [ko-fi.com/rosell](https://ko-fi.com/rosell), you can leave a wish. I shall take these wishes into account when prioritizing between new features.
599
600
+ ## Changes in 0.14.2
601
+ - Fixed problem with older versions of cwebp
602
+ - Fixed that images was not deleted
603
+ - Fixed cache problem on options page on systems that disables cache busting (it resulted in "SyntaxError: JSON.parse")
604
+
605
+
606
+ ## Changes in 0.14.1
607
+ - A little something
608
+
609
## Changes in 0.14.0
610
- Added new "encoding" option, which can be set to auto. This can in some cases dramatically reduce the size of the webp. It is supported by all converters except ewww and gd.
611
- Added new "near-lossless" option (only for cwebp and vips). Using this is a good idea for reducing size of lossless webps with an acceptable loss of quality
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.0
8
Requires PHP: 5.6
9
License: GPLv3
10
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -605,10 +605,17 @@ Easy enough! - [Go here!](https://ko-fi.com/rosell). Or [here](https://buymeacof
605
606
== Changelog ==
607
608
= 0.14.1 =
609
*(released: 15 jun 2019)*
610
611
- * Strengthened security
612
613
= 0.14.0 =
614
*(released: 15 jun 2019)*
@@ -802,8 +809,11 @@ For older releases, check out changelog.txt
802
803
== Upgrade Notice ==
804
805
= 0.14.1 =
806
- Strengthening security
807
808
= 0.14.0 =
809
New awesome conversion options that gets you even smaller webp files without compromising quality.
4
Tags: webp, images, performance
5
Requires at least: 4.0
6
Tested up to: 5.2
7
+ Stable tag: 0.14.2
8
Requires PHP: 5.6
9
License: GPLv3
10
License URI: https://www.gnu.org/licenses/gpl-3.0.html
605
606
== Changelog ==
607
608
+ = 0.14.2 =
609
+ *(released: 17 jun 2019)*
610
+
611
+ * Fixed problem with older versions of cwebp
612
+ * Fixed that images was not deleted
613
+ * Fixed cache problem on options page on systems that disables cache busting (it resulted in "SyntaxError: JSON.parse")
614
+
615
= 0.14.1 =
616
*(released: 15 jun 2019)*
617
618
+ * A little something
619
620
= 0.14.0 =
621
*(released: 15 jun 2019)*
809
810
== Upgrade Notice ==
811
812
+ = 0.14.2 =
813
+ A couple of bugfixes
814
+
815
= 0.14.1 =
816
+ A little something
817
818
= 0.14.0 =
819
New awesome conversion options that gets you even smaller webp files without compromising quality.
composer.json CHANGED
@@ -4,7 +4,7 @@
4
"type": "project",
5
"license": "MIT",
6
"require": {
7
- "rosell-dk/webp-convert": "^2.0.2",
8
"rosell-dk/webp-convert-cloud-service": "^2.0.0",
9
"rosell-dk/dom-util-for-webp": "^0.3.0"
10
},
4
"type": "project",
5
"license": "MIT",
6
"require": {
7
+ "rosell-dk/webp-convert": "^2.0.3",
8
"rosell-dk/webp-convert-cloud-service": "^2.0.0",
9
"rosell-dk/dom-util-for-webp": "^0.3.0"
10
},
composer.lock CHANGED
@@ -4,7 +4,7 @@
4
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
"This file is @generated automatically"
6
],
7
- "content-hash": "d1905bfab23d538f20fae2c74bb476a5",
8
"packages": [
9
{
10
"name": "rosell-dk/dom-util-for-webp",
@@ -118,16 +118,16 @@
118
},
119
{
120
"name": "rosell-dk/webp-convert",
121
- "version": "2.0.2",
122
"source": {
123
"type": "git",
124
"url": "https://github.com/rosell-dk/webp-convert.git",
125
- "reference": "50f59ca429ebe2984a4054696db62bcfcf57d299"
126
},
127
"dist": {
128
"type": "zip",
129
- "url": "https://api.github.com/repos/rosell-dk/webp-convert/zipball/50f59ca429ebe2984a4054696db62bcfcf57d299",
130
- "reference": "50f59ca429ebe2984a4054696db62bcfcf57d299",
131
"shasum": ""
132
},
133
"require": {
@@ -190,7 +190,7 @@
190
"png",
191
"png2webp"
192
],
193
- "time": "2019-06-15T11:45:10+00:00"
194
},
195
{
196
"name": "rosell-dk/webp-convert-cloud-service",
4
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
"This file is @generated automatically"
6
],
7
+ "content-hash": "195dde623afd5d43ce9443d4b6670585",
8
"packages": [
9
{
10
"name": "rosell-dk/dom-util-for-webp",
118
},
119
{
120
"name": "rosell-dk/webp-convert",
121
+ "version": "2.0.3",
122
"source": {
123
"type": "git",
124
"url": "https://github.com/rosell-dk/webp-convert.git",
125
+ "reference": "3a2c6ab330e4a99dbce1b05c987cad4f799f75ee"
126
},
127
"dist": {
128
"type": "zip",
129
+ "url": "https://api.github.com/repos/rosell-dk/webp-convert/zipball/3a2c6ab330e4a99dbce1b05c987cad4f799f75ee",
130
+ "reference": "3a2c6ab330e4a99dbce1b05c987cad4f799f75ee",
131
"shasum": ""
132
},
133
"require": {
190
"png",
191
"png2webp"
192
],
193
+ "time": "2019-06-17T08:13:22+00:00"
194
},
195
{
196
"name": "rosell-dk/webp-convert-cloud-service",
lib/alter-html.php CHANGED
@@ -1,5 +1,7 @@
1
<?php
2
3
function webPExpressAlterHtml($content) {
4
// Don't do anything with the RSS feed.
5
if (is_feed()) {
1
<?php
2
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
function webPExpressAlterHtml($content) {
6
// Don't do anything with the RSS feed.
7
if (is_feed()) {
lib/classes/AdminInit.php CHANGED
@@ -43,10 +43,34 @@ class AdminInit
43
44
public static function adminInitHandler()
45
{
46
- global $pagenow;
47
- if ((('options-general.php' === $pagenow) || (('settings.php' === $pagenow))) && (isset($_GET['page'])) && ('webp_express_settings_page' === $_GET['page'])) {
48
- add_action('admin_enqueue_scripts', array('\WebPExpress\OptionsPage', 'enqueueScripts'));
49
}
50
}
51
52
public static function addHooks()
@@ -57,33 +81,19 @@ class AdminInit
57
register_deactivation_hook(WEBPEXPRESS_PLUGIN, array('\WebPExpress\PluginDeactivate', 'deactivate'));
58
register_uninstall_hook(WEBPEXPRESS_PLUGIN, array('\WebPExpress\PluginUninstall', 'uninstall'));
59
60
- // Hooks related to options page
61
if (Multisite::isNetworkActivated()) {
62
add_action("network_admin_menu", array('\WebPExpress\AdminUi', 'networAdminMenuHook'));
63
} else {
64
add_action("admin_menu", array('\WebPExpress\AdminUi', 'adminMenuHook'));
65
}
66
- add_action("admin_post_webpexpress_settings_submit", array('\WebPExpress\OptionsPageHooks', 'submitHandler'));
67
- add_action("admin_init", array('\WebPExpress\AdminInit', 'adminInitHandler'));
68
-
69
70
// Print pending messages, if any
71
if (Option::getOption('webp-express-messages-pending')) {
72
add_action(Multisite::isNetworkActivated() ? 'network_admin_notices' : 'admin_notices', array('\WebPExpress\Messenger', 'printPendingMessages'));
73
}
74
75
- // Add settings link on the plugins page
76
- add_filter('plugin_action_links_' . plugin_basename(WEBPEXPRESS_PLUGIN), array('\WebPExpress\AdminUi', 'pluginActionLinksFilter'), 10, 2);
77
-
78
- // Add settings link in multisite
79
- add_filter('network_admin_plugin_action_links_' . plugin_basename(WEBPEXPRESS_PLUGIN), array('\WebPExpress\AdminUi', 'networkPluginActionLinksFilter'), 10, 2);
80
-
81
- // Ajax actions
82
- add_action('wp_ajax_list_unconverted_files', array('\WebPExpress\BulkConvert', 'processAjaxListUnconvertedFiles'));
83
- add_action('wp_ajax_convert_file', array('\WebPExpress\Convert', 'processAjaxConvertFile'));
84
- add_action('wp_ajax_webpexpress_view_log', array('\WebPExpress\ConvertLog', 'processAjaxViewLog'));
85
- add_action('wp_ajax_webpexpress_purge_cache', array('\WebPExpress\CachePurge', 'processAjaxPurgeCache'));
86
- add_action('wp_ajax_webpexpress_dismiss_message', array('\WebPExpress\DismissableMessages', 'processAjaxDismissMessage'));
87
88
// PS:
89
// Filters for processing upload hooks in order to convert images upon upload (wp_handle_upload / image_make_intermediate_size)
43
44
public static function adminInitHandler()
45
{
46
+
47
+ if (current_user_can('manage_options')) {
48
+
49
+ // Hooks related to options page
50
+
51
+ global $pagenow;
52
+ if ((('options-general.php' === $pagenow) || (('settings.php' === $pagenow))) && (isset($_GET['page'])) && ('webp_express_settings_page' === $_GET['page'])) {
53
+ add_action('admin_enqueue_scripts', array('\WebPExpress\OptionsPage', 'enqueueScripts'));
54
+ }
55
+
56
+ add_action("admin_post_webpexpress_settings_submit", array('\WebPExpress\OptionsPageHooks', 'submitHandler'));
57
+
58
+
59
+ // Ajax actions
60
+ add_action('wp_ajax_list_unconverted_files', array('\WebPExpress\BulkConvert', 'processAjaxListUnconvertedFiles'));
61
+ add_action('wp_ajax_convert_file', array('\WebPExpress\Convert', 'processAjaxConvertFile'));
62
+ add_action('wp_ajax_webpexpress_view_log', array('\WebPExpress\ConvertLog', 'processAjaxViewLog'));
63
+ add_action('wp_ajax_webpexpress_purge_cache', array('\WebPExpress\CachePurge', 'processAjaxPurgeCache'));
64
+ add_action('wp_ajax_webpexpress_dismiss_message', array('\WebPExpress\DismissableMessages', 'processAjaxDismissMessage'));
65
+
66
+
67
+ // Add settings link on the plugins page
68
+ add_filter('plugin_action_links_' . plugin_basename(WEBPEXPRESS_PLUGIN), array('\WebPExpress\AdminUi', 'pluginActionLinksFilter'), 10, 2);
69
+
70
+ // Add settings link in multisite
71
+ add_filter('network_admin_plugin_action_links_' . plugin_basename(WEBPEXPRESS_PLUGIN), array('\WebPExpress\AdminUi', 'networkPluginActionLinksFilter'), 10, 2);
72
}
73
+
74
}
75
76
public static function addHooks()
81
register_deactivation_hook(WEBPEXPRESS_PLUGIN, array('\WebPExpress\PluginDeactivate', 'deactivate'));
82
register_uninstall_hook(WEBPEXPRESS_PLUGIN, array('\WebPExpress\PluginUninstall', 'uninstall'));
83
84
+ add_action("admin_init", array('\WebPExpress\AdminInit', 'adminInitHandler'));
85
+
86
if (Multisite::isNetworkActivated()) {
87
add_action("network_admin_menu", array('\WebPExpress\AdminUi', 'networAdminMenuHook'));
88
} else {
89
add_action("admin_menu", array('\WebPExpress\AdminUi', 'adminMenuHook'));
90
}
91
92
// Print pending messages, if any
93
if (Option::getOption('webp-express-messages-pending')) {
94
add_action(Multisite::isNetworkActivated() ? 'network_admin_notices' : 'admin_notices', array('\WebPExpress\Messenger', 'printPendingMessages'));
95
}
96
97
98
// PS:
99
// Filters for processing upload hooks in order to convert images upon upload (wp_handle_upload / image_make_intermediate_size)
lib/classes/HandleDeleteFileHook.php CHANGED
@@ -17,13 +17,13 @@ class HandleDeleteFileHook
17
'image/png',
18
];
19
if (!Mime::isOneOfTheseImageMimeTypes($filename, $mimeTypes)) {
20
- return;
21
}
22
23
$destination = Convert::getDestination($filename);
24
if (!unlink($destination)) {
25
error_log('WebP Express failed deleting webp:' . $destination);
26
}
27
-
28
}
29
}
17
'image/png',
18
];
19
if (!Mime::isOneOfTheseImageMimeTypes($filename, $mimeTypes)) {
20
+ return $filename;
21
}
22
23
$destination = Convert::getDestination($filename);
24
if (!unlink($destination)) {
25
error_log('WebP Express failed deleting webp:' . $destination);
26
}
27
+ return $filename;
28
}
29
}
lib/debug.php CHANGED
@@ -1,5 +1,6 @@
1
<?php
2
3
4
function webpexpress_activated() {
5
update_option( 'webp-express-activation-error', ob_get_contents() );
1
<?php
2
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5
function webpexpress_activated() {
6
update_option( 'webp-express-activation-error', ob_get_contents() );
lib/options/enqueue_scripts.php CHANGED
@@ -1,13 +1,15 @@
1
<?php
2
3
include_once __DIR__ . '/../classes/Paths.php';
4
use \WebPExpress\Paths;
5
6
include_once __DIR__ . '/../classes/Config.php';
7
use \WebPExpress\Config;
8
9
- $version = '0.14.1';
10
-
11
12
if (!function_exists('webp_express_add_inline_script')) {
13
function webp_express_add_inline_script($id, $script, $position) {
@@ -20,10 +22,10 @@ if (!function_exists('webp_express_add_inline_script')) {
20
}
21
}
22
23
- wp_register_script('sortable', plugins_url('js/sortable.min.js', __FILE__), [], '1.9.0');
24
wp_enqueue_script('sortable');
25
26
- wp_register_script('daspopup', plugins_url('js/das-popup.js', __FILE__), [], $version);
27
wp_enqueue_script('daspopup');
28
29
$config = Config::getConfigForOptionsPage();
@@ -42,22 +44,22 @@ if (!(isset($config['operation-mode']) && ($config['operation-mode'] == 'no-conv
42
}
43
44
// Converters
45
- wp_register_script('converters', plugins_url('js/converters.js', __FILE__), ['sortable','daspopup'], $version);
46
webp_express_add_inline_script('converters', 'window.webpExpressPaths = ' . json_encode(Paths::getUrlsAndPathsForTheJavascript()) . ';', 'before');
47
webp_express_add_inline_script('converters', 'window.converters = ' . json_encode($config['converters']) . ';', 'before');
48
wp_enqueue_script('converters');
49
50
// Whitelist
51
- wp_register_script('whitelist', plugins_url('js/whitelist.js', __FILE__), ['daspopup'], $version);
52
webp_express_add_inline_script('whitelist', 'window.whitelist = ' . json_encode($config['web-service']['whitelist']) . ';', 'before');
53
wp_enqueue_script('whitelist');
54
55
// bulk convert
56
- wp_register_script('bulkconvert', plugins_url('js/bulk-convert.js', __FILE__), [], $version);
57
wp_enqueue_script('bulkconvert');
58
59
// test convert
60
- wp_register_script('testconvert', plugins_url('js/test-convert.js', __FILE__), [], $version);
61
$canDisplayWebp = (isset($_SERVER['HTTP_ACCEPT']) && (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false ));
62
63
/*
@@ -72,20 +74,20 @@ if (!(isset($config['operation-mode']) && ($config['operation-mode'] == 'no-conv
72
webp_express_add_inline_script('testconvert', 'window.canDisplayWebp = ' . ($canDisplayWebp ? 'true' : 'false') . ';', 'before');
73
wp_enqueue_script('testconvert');
74
75
- wp_register_script('image-comparison-slider', plugins_url('js/image-comparison-slider.js', __FILE__), [], $version);
76
wp_enqueue_script('image-comparison-slider');
77
78
79
// purge cache
80
- wp_register_script('purgecache', plugins_url('js/purge-cache.js', __FILE__), [], $version);
81
wp_enqueue_script('purgecache');
82
83
}
84
85
- //wp_register_script('api_keys', plugins_url('js/api-keys.js', __FILE__), ['daspopup'], '0.7.0-dev8');
86
//wp_enqueue_script('api_keys');
87
88
- wp_register_script( 'page', plugins_url('js/page.js', __FILE__), [], $version);
89
webp_express_add_inline_script(
90
'page',
91
'window.webpExpressAjaxConvertNonce = "' . wp_create_nonce('webpexpress-ajax-convert-nonce') . '";' .
@@ -98,13 +100,13 @@ wp_enqueue_script('page');
98
99
100
// Register styles
101
- wp_register_style('webp-express-options-page-css', plugins_url('css/webp-express-options-page.css', __FILE__), null, $version);
102
wp_enqueue_style('webp-express-options-page-css');
103
104
- wp_register_style('test-convert-css', plugins_url('css/test-convert.css', __FILE__), null, $version);
105
wp_enqueue_style('test-convert-css');
106
107
- wp_register_style('das-popup-css', plugins_url('css/das-popup.css', __FILE__), null, $version);
108
wp_enqueue_style('das-popup-css');
109
110
add_thickbox();
1
<?php
2
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
include_once __DIR__ . '/../classes/Paths.php';
6
use \WebPExpress\Paths;
7
8
include_once __DIR__ . '/../classes/Config.php';
9
use \WebPExpress\Config;
10
11
+ $ver = '1';
12
+ $jsDir = 'js/0.14.2';
13
14
if (!function_exists('webp_express_add_inline_script')) {
15
function webp_express_add_inline_script($id, $script, $position) {
22
}
23
}
24
25
+ wp_register_script('sortable', plugins_url($jsDir . '/sortable.min.js', __FILE__), [], '1.9.0');
26
wp_enqueue_script('sortable');
27
28
+ wp_register_script('daspopup', plugins_url($jsDir . '/das-popup.js', __FILE__), [], $ver);
29
wp_enqueue_script('daspopup');
30
31
$config = Config::getConfigForOptionsPage();
44
}
45
46
// Converters
47
+ wp_register_script('converters', plugins_url($jsDir . '/converters.js', __FILE__), ['sortable','daspopup'], $ver);
48
webp_express_add_inline_script('converters', 'window.webpExpressPaths = ' . json_encode(Paths::getUrlsAndPathsForTheJavascript()) . ';', 'before');
49
webp_express_add_inline_script('converters', 'window.converters = ' . json_encode($config['converters']) . ';', 'before');
50
wp_enqueue_script('converters');
51
52
// Whitelist
53
+ wp_register_script('whitelist', plugins_url($jsDir . '/whitelist.js', __FILE__), ['daspopup'], $ver);
54
webp_express_add_inline_script('whitelist', 'window.whitelist = ' . json_encode($config['web-service']['whitelist']) . ';', 'before');
55
wp_enqueue_script('whitelist');
56
57
// bulk convert
58
+ wp_register_script('bulkconvert', plugins_url($jsDir . '/bulk-convert.js', __FILE__), [], $ver);
59
wp_enqueue_script('bulkconvert');
60
61
// test convert
62
+ wp_register_script('testconvert', plugins_url($jsDir . '/test-convert.js', __FILE__), [], $ver);
63
$canDisplayWebp = (isset($_SERVER['HTTP_ACCEPT']) && (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false ));
64
65
/*
74
webp_express_add_inline_script('testconvert', 'window.canDisplayWebp = ' . ($canDisplayWebp ? 'true' : 'false') . ';', 'before');
75
wp_enqueue_script('testconvert');
76
77
+ wp_register_script('image-comparison-slider', plugins_url($jsDir . '/image-comparison-slider.js', __FILE__), [], $ver);
78
wp_enqueue_script('image-comparison-slider');
79
80
81
// purge cache
82
+ wp_register_script('purgecache', plugins_url($jsDir . '/purge-cache.js', __FILE__), [], $ver);
83
wp_enqueue_script('purgecache');
84
85
}
86
87
+ //wp_register_script('api_keys', plugins_url($jsDir . 'api-keys.js', __FILE__), ['daspopup'], '0.7.0-dev8');
88
//wp_enqueue_script('api_keys');
89
90
+ wp_register_script( 'page', plugins_url($jsDir . '/page.js', __FILE__), [], $ver);
91
webp_express_add_inline_script(
92
'page',
93
'window.webpExpressAjaxConvertNonce = "' . wp_create_nonce('webpexpress-ajax-convert-nonce') . '";' .
100
101
102
// Register styles
103
+ wp_register_style('webp-express-options-page-css', plugins_url('css/webp-express-options-page.css', __FILE__), null, $ver);
104
wp_enqueue_style('webp-express-options-page-css');
105
106
+ wp_register_style('test-convert-css', plugins_url('css/test-convert.css', __FILE__), null, $ver);
107
wp_enqueue_style('test-convert-css');
108
109
+ wp_register_style('das-popup-css', plugins_url('css/das-popup.css', __FILE__), null, $ver);
110
wp_enqueue_style('das-popup-css');
111
112
add_thickbox();
lib/options/js/{authorized_sites_bak.js → 0.14.2/authorized_sites_bak.js} RENAMED
File without changes
lib/options/js/{bulk-convert.js → 0.14.2/bulk-convert.js} RENAMED
File without changes
lib/options/js/{converters.js → 0.14.2/converters.js} RENAMED
File without changes
lib/options/js/{das-popup.js → 0.14.2/das-popup.js} RENAMED
File without changes
lib/options/js/{image-comparison-slider.js → 0.14.2/image-comparison-slider.js} RENAMED
File without changes
lib/options/js/{page.js → 0.14.2/page.js} RENAMED
File without changes
lib/options/js/{purge-cache.js → 0.14.2/purge-cache.js} RENAMED
File without changes
lib/options/js/{sortable.min.js → 0.14.2/sortable.min.js} RENAMED
File without changes
lib/options/js/{test-convert.js → 0.14.2/test-convert.js} RENAMED
File without changes
lib/options/js/{whitelist.js → 0.14.2/whitelist.js} RENAMED
File without changes
lib/options/js/{whitelist_old.js → 0.14.2/whitelist_old.js} RENAMED
File without changes
lib/options/page-messages.php CHANGED
@@ -1,5 +1,7 @@
1
<?php
2
3
use \WebPExpress\CapabilityTest;
4
use \WebPExpress\Config;
5
use \WebPExpress\ConvertersHelper;
1
<?php
2
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
use \WebPExpress\CapabilityTest;
6
use \WebPExpress\Config;
7
use \WebPExpress\ConvertersHelper;
lib/options/page-welcome.php CHANGED
@@ -1,5 +1,7 @@
1
<?php
2
3
use \WebPExpress\Paths;
4
use \WebPExpress\Config;
5
use \WebPExpress\State;
1
<?php
2
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
use \WebPExpress\Paths;
6
use \WebPExpress\Config;
7
use \WebPExpress\State;
lib/options/page.php CHANGED
@@ -1,5 +1,7 @@
1
<?php
2
3
use \WebPExpress\Config;
4
use \WebPExpress\ConvertersHelper;
5
use \WebPExpress\FileHelper;
1
<?php
2
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
use \WebPExpress\Config;
6
use \WebPExpress\ConvertersHelper;
7
use \WebPExpress\FileHelper;
lib/options/submit.php CHANGED
@@ -1,5 +1,7 @@
1
<?php
2
3
use \WebPExpress\CacheMover;
4
use \WebPExpress\CapabilityTest;
5
use \WebPExpress\Config;
1
<?php
2
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
use \WebPExpress\CacheMover;
6
use \WebPExpress\CapabilityTest;
7
use \WebPExpress\Config;
lib/wpc.php DELETED
@@ -1,266 +0,0 @@
1
- <?php
2
-
3
- //ini_set('display_errors', 1);
4
- //error_reporting(E_ALL);
5
-
6
- //require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
7
-
8
- include_once __DIR__ . '/classes/Config.php';
9
- use \WebPExpress\Config;
10
-
11
- include_once __DIR__ . '/classes/Paths.php';
12
- use \WebPExpress\Paths;
13
-
14
- include_once __DIR__ . '/classes/State.php';
15
- use \WebPExpress\State;
16
-
17
- require_once __DIR__ . '/../vendor/autoload.php';
18
- use WebPConvert\WebPConvert;
19
-
20
-
21
- const ERROR_SERVER_SETUP = 0;
22
- const ERROR_NOT_ALLOWED = 1;
23
- const ERROR_RUNTIME = 2;
24
-
25
- $action = (isset($_POST['action']) ? $_POST['action'] : 'convert');
26
-
27
- if ($action == 'request-access') {
28
- if (!(State::getState('listening', false))) {
29
- exitWithError(ERROR_NOT_ALLOWED, 'Server is not listening for requests');
30
- } else {
31
- State::setState('request', [
32
- 'label' => isset($_POST['label']) ? $_POST['label'] : 'unknown',
33
- 'key' => isset($_POST['key']) ? $_POST['key'] : 'prut2',
34
- 'ip' => $_SERVER['REMOTE_ADDR'],
35
- 'timestamp' => time(),
36
- ]);
37
- $returnObject = [
38
- 'success' => 1,
39
- ];
40
- echo json_encode($returnObject);
41
- die();
42
- }
43
- }
44
-
45
-
46
-
47
- function exitWithError($errorCode, $msg)
48
- {
49
- $returnObject = [
50
- 'success' => 0,
51
- 'errorCode' => $errorCode,
52
- 'errorMessage' => $msg,
53
- ];
54
- echo json_encode($returnObject);
55
- exit;
56
- }
57
-
58
- $config = Config::loadConfig();
59
- if ($config === false) {
60
- if (Config::isConfigFileThere()) {
61
- exitWithError(ERROR_SERVER_SETUP, 'config file could not be loaded.');
62
- } else {
63
- exitWithError(ERROR_SERVER_SETUP, 'config file could not be loaded (its not there): ' . Paths::getConfigFileName());
64
- }
65
- }
66
-
67
- if (!isset($config['wpc'])) {
68
- exitWithError(ERROR_SERVER_SETUP, 'cloud service is not configured');
69
- }
70
-
71
- $wpcOptions = $config['wpc'];
72
-
73
- if (!isset($wpcOptions['enabled']) || $wpcOptions['enabled'] == false) {
74
- exitWithError(ERROR_SERVER_SETUP, 'cloud service is not enabled');
75
- }
76
-
77
- $whitelisted = false;
78
- $password = '';
79
-
80
- /**
81
- * Note about the whitelist:
82
- * It is not unspoofable. But it does not have to be either.
83
- * The extra layer of "security" is added to avoid massive misuse in case that the password
84
- * is leaked. Massive misuse would be if the password where to spread in internet forums, and
85
- * anyone could easily use it. With the whitelist, the password is not enough, you would also
86
- * be needing to know an entry on the whitelist. This could of course also be leaked. But you
87
- * would also need to do the spoofing. This additional step is probably more than most people
88
- * would bother to go through.
89
- */
90
- function testWhitelistEntry($sitePattern) {
91
- if ($sitePattern == '*') {
92
- return true;
93
- }
94
- $regEx = '/^' . str_replace('*', '.*', $sitePattern) . '#x2F;';
95
-
96
- $ip = $_SERVER['REMOTE_ADDR'];
97
- if (preg_match($regEx, $ip)) {
98
- return true;
99
- }
100
-
101
- // If sitePattern looks like a full IP pattern, exit now,
102
- // so the other methods cant be misused with spoofing.
103
- // ^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$
104
- if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}#x2F;', $sitePattern)) {
105
- return false;
106
- }
107
- // Also test a nearly full IP pattern.
108
- // As domain names may now start with numbers, theoretically, we could have a domain
109
- // called 123.127.com, and the user might also have 123.127.net, and therefore add
110
- // a rule '123.127.*'.
111
- if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.?\\*#x2F;', $sitePattern)) {
112
- return false;
113
- }
114
-
115
- // ^(\d{1,3}(\.)?){1,4}\*?$ works in regexr.com, but not here...
116
-
117
- if (isset($_SERVER['REMOTE_HOST'])) {
118
- // REMOTE_HOST is only available if Apache has been configured
119
- // with HostnameLookups = On (in apache.conf).
120
- // It seldom is, as it is not the default, and it is expensive,as at least one
121
- // DNS lookup will be made per request.
122
- // Anyway, here we are, and we have it.
123
- if (preg_match($regEx, $_SERVER['REMOTE_HOST'])) {
124
- return true;
125
- }
126
- }
127
-
128
- // I know, it can easily be spoofed, simply by changing the source code.
129
- // However, encrypting it would not help, as the bandit would already be
130
- // knowing the secret.
131
- // - And $_SERVER['REMOTE_HOST'] is seldom available, and often misleading
132
- // on shared hosts
133
- if (isset($_POST['servername'])) {
134
- $domain = $_POST['servername'];
135
- if (preg_match($regEx, $_POST['servername'])) {
136
- return true;
137
- }
138
- }
139
-
140
- return false;
141
- }
142
-
143
- foreach ($wpcOptions['whitelist'] as $entry) {
144
- if (testWhitelistEntry($entry['site'])) {
145
- $whitelisted = true;
146
- $password = $entry['password'];
147
- break;
148
- }
149
- }
150
-
151
- if (!$whitelisted) {
152
- if (isset($_SERVER['REMOTE_HOST']) && (!empty($_SERVER['REMOTE_HOST']))) {
153
- if (isset($_POST['servername'])) {
154
- exitWithError(ERROR_NOT_ALLOWED, 'Neither your domain (' . $_POST['servername'] . '), the domain of your webhost (' . $_SERVER['REMOTE_HOST'] . ') or your IP (' . $_SERVER['REMOTE_ADDR'] . ') is on the whitelist');
155
- } else {
156
- exitWithError(ERROR_NOT_ALLOWED, 'Neither the domain of your webhost (' . $_SERVER['REMOTE_HOST'] . ') or your IP (' . $_SERVER['REMOTE_ADDR'] . ') is on the whitelist');
157
- }
158
- } else {
159
- if (isset($_POST['servername'])) {
160
- exitWithError(ERROR_NOT_ALLOWED, 'Neither your domain (' . $_POST['servername'] . ') or your IP (' . $_SERVER['REMOTE_ADDR'] . ') is on the whitelist');
161
- } else {
162
- exitWithError(ERROR_NOT_ALLOWED, 'Your IP (' . $_SERVER['REMOTE_ADDR'] . ') is not on the whitelist');
163
- }
164
- }
165
- }
166
-
167
- $uploaddir = Paths::getCacheDirAbs() . '/wpc';
168
-
169
- if (!is_dir($uploaddir)) {
170
- if (!@mkdir($uploaddir, 0775, true)) {
171
- exitWithError(ERROR_SERVER_SETUP, 'Could not create folder for converted files: ' . $uploaddir);
172
- }
173
- @chmod($uploaddir, 0775);
174
- }
175
-
176
-
177
- if (!isset($_POST['hash'])) {
178
- exitWithError(ERROR_NOT_ALLOWED, 'Restricted access. Hash required, but missing');
179
- }
180
-
181
- if (!isset($_FILES['file']['error'])) {
182
- exitWithError(ERROR_RUNTIME, 'Invalid parameters');
183
- }
184
-
185
- if (is_array($_FILES['file']['error'])) {
186
- exitWithError(ERROR_RUNTIME, 'Cannot convert multiple files');
187
- }
188
-
189
- switch ($_FILES['file']['error']) {
190
- case UPLOAD_ERR_OK:
191
- break;
192
- case UPLOAD_ERR_NO_FILE:
193
- exitWithError(ERROR_RUNTIME, 'No file sent');
194
- case UPLOAD_ERR_INI_SIZE:
195
- case UPLOAD_ERR_FORM_SIZE:
196
- exitWithError(ERROR_RUNTIME, 'Exceeded filesize limit.');
197
- default:
198
- exitWithError(ERROR_RUNTIME, 'Unknown error.');
199
- }
200
-
201
- if ($_FILES['file']['size'] == 0) {
202
- exitWithError(ERROR_NOT_ALLOWED, 'File size is zero. Perhaps exceeded filesize limit?');
203
- }
204
- // Undefined | Multiple Files | $_FILES Corruption Attack
205
- // If this request falls under any of them, treat it invalid.
206
- /*if ($_FILES['file']['size'] > 1000000) {
207
- throw new RuntimeException('Exceeded filesize limit.');
208
- }*/
209
-
210
- // DO NOT TRUST $_FILES['upfile']['mime'] VALUE !!
211
- // Check MIME Type by yourself.
212
- $finfo = new finfo(FILEINFO_MIME_TYPE);
213
- if (false === $ext = array_search(
214
- $finfo->file($_FILES['file']['tmp_name']),
215
- array(
216
- 'jpg' => 'image/jpeg',
217
- 'png' => 'image/png',
218
- 'gif' => 'image/gif',
219
- ),
220
- true
221
- )) {
222
- exitWithError(ERROR_NOT_ALLOWED, 'Invalid file format.');
223
- }
224
-
225
- $uploadfile = $uploaddir . '/' . sha1_file($_FILES['file']['tmp_name']) . '.' . $ext;
226
- //echo $uploadfile;
227
- if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
228
- // File is valid, and was successfully uploaded
229
-
230
- $source = $uploadfile;
231
-
232
- if (!empty($password)) {
233
- $hash = md5(md5_file($source) . $password);
234
-
235
- if ($hash != $_POST['hash']) {
236
- exitWithError(ERROR_NOT_ALLOWED, 'Wrong password.');
237
- }
238
- }
239
-
240
- $destination = $uploadfile . '.webp';
241
-
242
- // Merge in options in $_POST, overwriting those in config.yaml
243
- $convertOptionsInPost = (array) json_decode($_POST['options']);
244
- $options = Config::generateWodOptionsFromConfigObj($config);
245
- $convertOptions = array_merge($options, $convertOptionsInPost);
246
-
247
- try {
248
- if (WebPConvert::convert($source, $destination, $convertOptions)) {
249
- header('Content-type: application/octet-stream');
250
- echo file_get_contents($destination);
251
-
252
- unlink($source);
253
- unlink($destination);
254
- } else {
255
- echo 'no converters could convert the image';
256
- }
257
- } catch (\Exception $e) {
258
- echo 'failed!';
259
- echo $e->getMessage();
260
- }
261
- } else {
262
- // Possible file upload attack!
263
- exitWithError(ERROR_SERVER_SETUP, 'Failed to move uploaded file');
264
-
265
- //echo 'Failed to move uploaded file';
266
- }
vendor/composer/autoload_classmap.php CHANGED
@@ -6,4 +6,82 @@ $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\\SourceValidationTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/SourceValidationTrait.php',
30
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\WarningLoggerTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/WarningLoggerTrait.php',
31
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\CloudConverterTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/CloudConverterTrait.php',
32
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\CurlTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/CurlTrait.php',
33
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\EncodingAutoTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/EncodingAutoTrait.php',
34
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\ExecTrait' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/ExecTrait.php',
35
+ 'WebPConvert\\Convert\\Converters\\Cwebp' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php',
36
+ 'WebPConvert\\Convert\\Converters\\Ewww' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Ewww.php',
37
+ 'WebPConvert\\Convert\\Converters\\Gd' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Gd.php',
38
+ 'WebPConvert\\Convert\\Converters\\Gmagick' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Gmagick.php',
39
+ 'WebPConvert\\Convert\\Converters\\GmagickBinary' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/GmagickBinary.php',
40
+ 'WebPConvert\\Convert\\Converters\\GraphicsMagick' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/GraphicsMagick.php',
41
+ 'WebPConvert\\Convert\\Converters\\ImageMagick' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ImageMagick.php',
42
+ 'WebPConvert\\Convert\\Converters\\Imagick' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Imagick.php',
43
+ 'WebPConvert\\Convert\\Converters\\ImagickBinary' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/ImagickBinary.php',
44
+ 'WebPConvert\\Convert\\Converters\\Stack' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Stack.php',
45
+ 'WebPConvert\\Convert\\Converters\\Vips' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Vips.php',
46
+ 'WebPConvert\\Convert\\Converters\\Wpc' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Converters/Wpc.php',
47
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailedException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailedException.php',
48
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConversionSkippedException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConversionSkippedException.php',
49
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperationalException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperationalException.php',
50
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperational\\InvalidApiKeyException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperational/InvalidApiKeyException.php',
51
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperational\\SystemRequirementsNotMetException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperational/SystemRequirementsNotMetException.php',
52
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblemsException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblemsException.php',
53
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblems\\CreateDestinationFileException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblems/CreateDestinationFileException.php',
54
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblems\\CreateDestinationFolderException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblems/CreateDestinationFolderException.php',
55
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInputException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInputException.php',
56
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\ConverterNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/ConverterNotFoundException.php',
57
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\InvalidImageTypeException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/InvalidImageTypeException.php',
58
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\TargetNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/TargetNotFoundException.php',
59
+ 'WebPConvert\\Convert\\Helpers\\JpegQualityDetector' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Helpers/JpegQualityDetector.php',
60
+ 'WebPConvert\\Convert\\Helpers\\PhpIniSizes' => $vendorDir . '/rosell-dk/webp-convert/src/Convert/Helpers/PhpIniSizes.php',
61
+ 'WebPConvert\\Exceptions\\WebPConvertException' => $vendorDir . '/rosell-dk/webp-convert/src/Exceptions/WebPConvertException.php',
62
+ 'WebPConvert\\Loggers\\BaseLogger' => $vendorDir . '/rosell-dk/webp-convert/src/Loggers/BaseLogger.php',
63
+ 'WebPConvert\\Loggers\\BufferLogger' => $vendorDir . '/rosell-dk/webp-convert/src/Loggers/BufferLogger.php',
64
+ 'WebPConvert\\Loggers\\EchoLogger' => $vendorDir . '/rosell-dk/webp-convert/src/Loggers/EchoLogger.php',
65
+ 'WebPConvert\\Options\\ArrayOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/ArrayOption.php',
66
+ 'WebPConvert\\Options\\BooleanOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/BooleanOption.php',
67
+ 'WebPConvert\\Options\\Exceptions\\InvalidOptionTypeException' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Exceptions/InvalidOptionTypeException.php',
68
+ 'WebPConvert\\Options\\Exceptions\\InvalidOptionValueException' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Exceptions/InvalidOptionValueException.php',
69
+ 'WebPConvert\\Options\\Exceptions\\OptionNotFoundException' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Exceptions/OptionNotFoundException.php',
70
+ 'WebPConvert\\Options\\GhostOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/GhostOption.php',
71
+ 'WebPConvert\\Options\\IntegerOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/IntegerOption.php',
72
+ 'WebPConvert\\Options\\IntegerOrNullOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php',
73
+ 'WebPConvert\\Options\\MetadataOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/MetadataOption.php',
74
+ 'WebPConvert\\Options\\Option' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Option.php',
75
+ 'WebPConvert\\Options\\Options' => $vendorDir . '/rosell-dk/webp-convert/src/Options/Options.php',
76
+ 'WebPConvert\\Options\\QualityOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/QualityOption.php',
77
+ 'WebPConvert\\Options\\SensitiveArrayOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/SensitiveArrayOption.php',
78
+ 'WebPConvert\\Options\\SensitiveStringOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/SensitiveStringOption.php',
79
+ 'WebPConvert\\Options\\StringOption' => $vendorDir . '/rosell-dk/webp-convert/src/Options/StringOption.php',
80
+ 'WebPConvert\\Serve\\Exceptions\\ServeFailedException' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/Exceptions/ServeFailedException.php',
81
+ 'WebPConvert\\Serve\\Header' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/Header.php',
82
+ 'WebPConvert\\Serve\\Report' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/Report.php',
83
+ 'WebPConvert\\Serve\\ServeConvertedWebP' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/ServeConvertedWebP.php',
84
+ 'WebPConvert\\Serve\\ServeConvertedWebPWithErrorHandling' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/ServeConvertedWebPWithErrorHandling.php',
85
+ 'WebPConvert\\Serve\\ServeFile' => $vendorDir . '/rosell-dk/webp-convert/src/Serve/ServeFile.php',
86
+ 'WebPConvert\\WebPConvert' => $vendorDir . '/rosell-dk/webp-convert/src/WebPConvert.php',
87
);
vendor/composer/autoload_static.php CHANGED
@@ -41,11 +41,93 @@ 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
}
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\\SourceValidationTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/SourceValidationTrait.php',
66
+ 'WebPConvert\\Convert\\Converters\\BaseTraits\\WarningLoggerTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/BaseTraits/WarningLoggerTrait.php',
67
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\CloudConverterTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/CloudConverterTrait.php',
68
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\CurlTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/CurlTrait.php',
69
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\EncodingAutoTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/EncodingAutoTrait.php',
70
+ 'WebPConvert\\Convert\\Converters\\ConverterTraits\\ExecTrait' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ConverterTraits/ExecTrait.php',
71
+ 'WebPConvert\\Convert\\Converters\\Cwebp' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php',
72
+ 'WebPConvert\\Convert\\Converters\\Ewww' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Ewww.php',
73
+ 'WebPConvert\\Convert\\Converters\\Gd' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Gd.php',
74
+ 'WebPConvert\\Convert\\Converters\\Gmagick' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Gmagick.php',
75
+ 'WebPConvert\\Convert\\Converters\\GmagickBinary' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/GmagickBinary.php',
76
+ 'WebPConvert\\Convert\\Converters\\GraphicsMagick' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/GraphicsMagick.php',
77
+ 'WebPConvert\\Convert\\Converters\\ImageMagick' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ImageMagick.php',
78
+ 'WebPConvert\\Convert\\Converters\\Imagick' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Imagick.php',
79
+ 'WebPConvert\\Convert\\Converters\\ImagickBinary' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/ImagickBinary.php',
80
+ 'WebPConvert\\Convert\\Converters\\Stack' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Stack.php',
81
+ 'WebPConvert\\Convert\\Converters\\Vips' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Vips.php',
82
+ 'WebPConvert\\Convert\\Converters\\Wpc' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Converters/Wpc.php',
83
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailedException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailedException.php',
84
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConversionSkippedException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConversionSkippedException.php',
85
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperationalException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperationalException.php',
86
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperational\\InvalidApiKeyException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperational/InvalidApiKeyException.php',
87
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\ConverterNotOperational\\SystemRequirementsNotMetException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/ConverterNotOperational/SystemRequirementsNotMetException.php',
88
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblemsException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblemsException.php',
89
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblems\\CreateDestinationFileException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblems/CreateDestinationFileException.php',
90
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\FileSystemProblems\\CreateDestinationFolderException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/FileSystemProblems/CreateDestinationFolderException.php',
91
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInputException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInputException.php',
92
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\ConverterNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/ConverterNotFoundException.php',
93
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\InvalidImageTypeException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/InvalidImageTypeException.php',
94
+ 'WebPConvert\\Convert\\Exceptions\\ConversionFailed\\InvalidInput\\TargetNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Exceptions/ConversionFailed/InvalidInput/TargetNotFoundException.php',
95
+ 'WebPConvert\\Convert\\Helpers\\JpegQualityDetector' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Helpers/JpegQualityDetector.php',
96
+ 'WebPConvert\\Convert\\Helpers\\PhpIniSizes' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Convert/Helpers/PhpIniSizes.php',
97
+ 'WebPConvert\\Exceptions\\WebPConvertException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Exceptions/WebPConvertException.php',
98
+ 'WebPConvert\\Loggers\\BaseLogger' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Loggers/BaseLogger.php',
99
+ 'WebPConvert\\Loggers\\BufferLogger' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Loggers/BufferLogger.php',
100
+ 'WebPConvert\\Loggers\\EchoLogger' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Loggers/EchoLogger.php',
101
+ 'WebPConvert\\Options\\ArrayOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/ArrayOption.php',
102
+ 'WebPConvert\\Options\\BooleanOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/BooleanOption.php',
103
+ 'WebPConvert\\Options\\Exceptions\\InvalidOptionTypeException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Exceptions/InvalidOptionTypeException.php',
104
+ 'WebPConvert\\Options\\Exceptions\\InvalidOptionValueException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Exceptions/InvalidOptionValueException.php',
105
+ 'WebPConvert\\Options\\Exceptions\\OptionNotFoundException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Exceptions/OptionNotFoundException.php',
106
+ 'WebPConvert\\Options\\GhostOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/GhostOption.php',
107
+ 'WebPConvert\\Options\\IntegerOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/IntegerOption.php',
108
+ 'WebPConvert\\Options\\IntegerOrNullOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/IntegerOrNullOption.php',
109
+ 'WebPConvert\\Options\\MetadataOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/MetadataOption.php',
110
+ 'WebPConvert\\Options\\Option' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Option.php',
111
+ 'WebPConvert\\Options\\Options' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/Options.php',
112
+ 'WebPConvert\\Options\\QualityOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/QualityOption.php',
113
+ 'WebPConvert\\Options\\SensitiveArrayOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/SensitiveArrayOption.php',
114
+ 'WebPConvert\\Options\\SensitiveStringOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/SensitiveStringOption.php',
115
+ 'WebPConvert\\Options\\StringOption' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Options/StringOption.php',
116
+ 'WebPConvert\\Serve\\Exceptions\\ServeFailedException' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/Exceptions/ServeFailedException.php',
117
+ 'WebPConvert\\Serve\\Header' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/Header.php',
118
+ 'WebPConvert\\Serve\\Report' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/Report.php',
119
+ 'WebPConvert\\Serve\\ServeConvertedWebP' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/ServeConvertedWebP.php',
120
+ 'WebPConvert\\Serve\\ServeConvertedWebPWithErrorHandling' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/ServeConvertedWebPWithErrorHandling.php',
121
+ 'WebPConvert\\Serve\\ServeFile' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/Serve/ServeFile.php',
122
+ 'WebPConvert\\WebPConvert' => __DIR__ . '/..' . '/rosell-dk/webp-convert/src/WebPConvert.php',
123
+ );
124
+
125
public static function getInitializer(ClassLoader $loader)
126
{
127
return \Closure::bind(function () use ($loader) {
128
$loader->prefixLengthsPsr4 = ComposerStaticInit9a5d1d521aac5c1f4f08f3a90858f030::$prefixLengthsPsr4;
129
$loader->prefixDirsPsr4 = ComposerStaticInit9a5d1d521aac5c1f4f08f3a90858f030::$prefixDirsPsr4;
130
+ $loader->classMap = ComposerStaticInit9a5d1d521aac5c1f4f08f3a90858f030::$classMap;
131
132
}, null, ClassLoader::class);
133
}
vendor/composer/installed.json CHANGED
@@ -115,17 +115,17 @@
115
},
116
{
117
"name": "rosell-dk/webp-convert",
118
- "version": "2.0.2",
119
- "version_normalized": "2.0.2.0",
120
"source": {
121
"type": "git",
122
"url": "https://github.com/rosell-dk/webp-convert.git",
123
- "reference": "50f59ca429ebe2984a4054696db62bcfcf57d299"
124
},
125
"dist": {
126
"type": "zip",
127
- "url": "https://api.github.com/repos/rosell-dk/webp-convert/zipball/50f59ca429ebe2984a4054696db62bcfcf57d299",
128
- "reference": "50f59ca429ebe2984a4054696db62bcfcf57d299",
129
"shasum": ""
130
},
131
"require": {
@@ -143,7 +143,7 @@
143
"ext-vips": "to use Vips extension for converting.",
144
"php-stan/php-stan": "Suggested for dev, in order to analyse code before committing"
145
},
146
- "time": "2019-06-15T11:45:10+00:00",
147
"type": "library",
148
"extra": {
149
"scripts-descriptions": {
115
},
116
{
117
"name": "rosell-dk/webp-convert",
118
+ "version": "2.0.3",
119
+ "version_normalized": "2.0.3.0",
120
"source": {
121
"type": "git",
122
"url": "https://github.com/rosell-dk/webp-convert.git",
123
+ "reference": "3a2c6ab330e4a99dbce1b05c987cad4f799f75ee"
124
},
125
"dist": {
126
"type": "zip",
127
+ "url": "https://api.github.com/repos/rosell-dk/webp-convert/zipball/3a2c6ab330e4a99dbce1b05c987cad4f799f75ee",
128
+ "reference": "3a2c6ab330e4a99dbce1b05c987cad4f799f75ee",
129
"shasum": ""
130
},
131
"require": {
143
"ext-vips": "to use Vips extension for converting.",
144
"php-stan/php-stan": "Suggested for dev, in order to analyse code before committing"
145
},
146
+ "time": "2019-06-17T08:13:22+00:00",
147
"type": "library",
148
"extra": {
149
"scripts-descriptions": {
vendor/rosell-dk/webp-convert/docs/v2.0/converting/introduction-for-converting.md CHANGED
@@ -80,15 +80,19 @@ Stack::convert($source, $destination, $options = [
80
], $logger=null);
81
```
82
83
- Note: As an alternative to setting the third party credentials in the options, you can set them through environment variables ("EWWW_API_KEY", "WPC_API_KEY", "WPC_API_URL"). Paths to binaries can also be set with environment variables (it is rarely needed to do this): "CWEBP_PATH", "GRAPHICSMAGICK_PATH" and IMAGEMAGICK_PATH"
84
85
To set an environment variable in Apache, you can add a line like this in your `.htaccess` or vhost configuration:
86
```
87
# Set ewww api key for WebP Convert
88
- SetEnv EWWW_API_KEY yourVerySecretApiKeyGoesHere
89
90
# Set custom path to imagick for WebP Convert
91
- SetEnv IMAGEMAGICK_PATH /usr/local/bin/magick
92
```
93
94
80
], $logger=null);
81
```
82
83
+ Note: As an alternative to setting the third party credentials in the options, you can set them through constants or environment variables ("WEBPCONVERT_EWWW_API_KEY", "WEBPCONVERT_WPC_API_KEY", "WEBPCONVERT_WPC_API_URL"). Paths to binaries can also be set like that (it is rarely needed to do this): "WEBPCONVERT_CWEBP_PATH", "WEBPCONVERT_GRAPHICSMAGICK_PATH" and WEBPCONVERT_IMAGEMAGICK_PATH"
84
85
To set an environment variable in Apache, you can add a line like this in your `.htaccess` or vhost configuration:
86
```
87
# Set ewww api key for WebP Convert
88
+ SetEnv WEBPCONVERT_EWWW_API_KEY yourVerySecretApiKeyGoesHere
89
90
# Set custom path to imagick for WebP Convert
91
+ SetEnv WEBPCONVERT_IMAGEMAGICK_PATH /usr/local/bin/magick
92
+ ```
93
+ To set a constant:
94
+ ```php
95
+ define('WEBPCONVERT_IMAGEMAGICK_PATH', '/usr/local/bin/magick');
96
```
97
98
vendor/rosell-dk/webp-convert/src-build/webp-convert.inc CHANGED
@@ -461,7 +461,7 @@ abstract class AbstractConverter
461
if (isset($trace['file']) && isset($trace['line'])) {
462
$this->logLn(
463
$trace['file'] . ':' . $trace['line']
464
- );
465
}
466
}
467
throw $e;
@@ -518,6 +518,8 @@ abstract class AbstractConverter
518
public function getMimeTypeOfSource()
519
{
520
if (!isset($this->sourceMimeType)) {
521
$this->sourceMimeType = ImageMimeTypeGuesser::lenientGuess($this->source);
522
}
523
return $this->sourceMimeType;
@@ -2161,7 +2163,9 @@ trait EncodingAutoTrait
2161
abstract public function getOptions();
2162
abstract protected function setOption($optionName, $optionValue);
2163
abstract protected function logLn($msg, $style = '');
2164
abstract protected function ln();
2165
2166
public function supportsLossless()
2167
{
@@ -2359,12 +2363,14 @@ class Cwebp extends AbstractConverter
2359
// OS-specific binaries included in this library, along with hashes
2360
// If other binaries are going to be added, notice that the first argument is what PHP_OS returns.
2361
// (possible values, see here: https://stackoverflow.com/questions/738823/possible-values-for-php-os)
2362
private static $suppliedBinariesInfo = [
2363
'WINNT' => [ 'cwebp.exe', '49e9cb98db30bfa27936933e6fd94d407e0386802cb192800d9fd824f6476873'],
2364
'Darwin' => [ 'cwebp-mac12', 'a06a3ee436e375c89dbc1b0b2e8bd7729a55139ae072ed3f7bd2e07de0ebb379'],
2365
'SunOS' => [ 'cwebp-sol', '1febaffbb18e52dc2c524cda9eefd00c6db95bc388732868999c0f48deb73b4f'],
2366
'FreeBSD' => [ 'cwebp-fbsd', 'e5cbea11c97fadffe221fdf57c093c19af2737e4bbd2cb3cd5e908de64286573'],
2367
- 'Linux' => [ 'cwebp-linux', '916623e5e9183237c851374d969aebdb96e0edc0692ab7937b95ea67dc3b2568']
2368
];
2369
2370
public function checkOperationality()
@@ -2383,10 +2389,13 @@ class Cwebp extends AbstractConverter
2383
2384
private function executeBinary($binary, $commandOptions, $useNice)
2385
{
2386
$command = ($useNice ? 'nice ' : '') . $binary . ' ' . $commandOptions;
2387
2388
//$logger->logLn('command options:' . $commandOptions);
2389
- //$logger->logLn('Trying to execute binary:' . $binary);
2390
exec($command, $output, $returnCode);
2391
$this->logExecOutput($output);
2392
/*
@@ -2440,19 +2449,42 @@ class Cwebp extends AbstractConverter
2440
}
2441
2442
/**
2443
- * Build command line options
2444
*
2445
* @return string
2446
*/
2447
- private function createCommandLineOptions()
2448
{
2449
$options = $this->options;
2450
2451
$cmdOptions = [];
2452
2453
// Metadata (all, exif, icc, xmp or none (default))
2454
// Comma-separated list of existing metadata to copy from input to output
2455
- $cmdOptions[] = '-metadata ' . $options['metadata'];
2456
2457
// preset. Appears first in the list as recommended in the docs
2458
if (!is_null($options['preset'])) {
@@ -2484,18 +2516,31 @@ class Cwebp extends AbstractConverter
2484
2485
// Losless PNG conversion
2486
if ($options['encoding'] == 'lossless') {
2487
- // No need to add -lossless when near-lossless is used
2488
- if ($options['near-lossless'] === 100) {
2489
$cmdOptions[] = '-lossless';
2490
}
2491
}
2492
2493
// Near-lossles
2494
if ($options['near-lossless'] !== 100) {
2495
- // We only let near_lossless have effect when encoding is set to "lossless"
2496
- // otherwise encoding=auto would not work as expected
2497
- if ($options['encoding'] == 'lossless') {
2498
- $cmdOptions[] ='-near_lossless ' . $options['near-lossless'];
2499
}
2500
}
2501
@@ -2530,117 +2575,27 @@ class Cwebp extends AbstractConverter
2530
$cmdOptions[] = '2>&1';
2531
2532
$commandOptions = implode(' ', $cmdOptions);
2533
- $this->logLn('command line options:' . $commandOptions);
2534
2535
return $commandOptions;
2536
}
2537
2538
/**
2539
*
2540
- *
2541
- * @return string Error message if failure, empty string if successful
2542
- */
2543
- private function composeErrorMessageForCommonSystemPathsFailures($failureCodes)
2544
- {
2545
- if (count($failureCodes) == 1) {
2546
- switch ($failureCodes[0]) {
2547
- case 126:
2548
- return 'Permission denied. The user that the command was run with (' .
2549
- shell_exec('whoami') . ') does not have permission to execute any of the ' .
2550
- 'cweb binaries found in common system locations. ';
2551
- case 127:
2552
- return 'Found no cwebp binaries in any common system locations. ';
2553
- default:
2554
- return 'Tried executing cwebp binaries in common system locations. ' .
2555
- 'All failed (exit code: ' . $failureCodes[0] . '). ';
2556
- }
2557
- } else {
2558
- /**
2559
- * $failureCodesBesides127 is used to check first position ($failureCodesBesides127[0])
2560
- * however position can vary as index can be 1 or something else. array_values() would
2561
- * always start from 0.
2562
- */
2563
- $failureCodesBesides127 = array_values(array_diff($failureCodes, [127]));
2564
-
2565
- if (count($failureCodesBesides127) == 1) {
2566
- switch ($failureCodesBesides127[0]) {
2567
- case 126:
2568
- return 'Permission denied. The user that the command was run with (' .
2569
- shell_exec('whoami') . ') does not have permission to execute any of the cweb ' .
2570
- 'binaries found in common system locations. ';
2571
- break;
2572
- default:
2573
- return 'Tried executing cwebp binaries in common system locations. ' .
2574
- 'All failed (exit code: ' . $failureCodesBesides127[0] . '). ';
2575
- }
2576
- } else {
2577
- return 'None of the cwebp binaries in the common system locations could be executed ' .
2578
- '(mixed results - got the following exit codes: ' . implode(',', $failureCodes) . '). ';
2579
- }
2580
- }
2581
- }
2582
-
2583
- /**
2584
- * Try executing cwebp in common system paths
2585
- *
2586
- * @param boolean $useNice Whether to use nice
2587
- * @param string $commandOptions for the exec call
2588
- *
2589
- * @return array Unique failure codes in case of failure, empty array in case of success
2590
- */
2591
- private function tryCommonSystemPaths($useNice, $commandOptions)
2592
- {
2593
- $failureCodes = [];
2594
-
2595
- $paths = self::$cwebpDefaultPaths;
2596
-
2597
- if (!empty(getenv('CWEBP_PATH'))) {
2598
- array_unshift($paths, getenv('CWEBP_PATH'));
2599
- }
2600
-
2601
- // Loop through paths
2602
- foreach ($paths as $index => $binary) {
2603
- $returnCode = $this->executeBinary($binary, $commandOptions, $useNice);
2604
- if ($returnCode == 0) {
2605
- $this->logLn('Successfully executed binary: ' . $binary);
2606
- return [];
2607
- } else {
2608
- if ($returnCode == 127) {
2609
- $this->logLn(
2610
- 'Trying to execute binary: ' . $binary . '. Failed (not found)'
2611
- );
2612
- } else {
2613
- $this->logLn(
2614
- 'Trying to execute binary: ' . $binary . '. Failed (return code: ' . $returnCode . ')'
2615
- );
2616
- }
2617
- if (!in_array($returnCode, $failureCodes)) {
2618
- $failureCodes[] = $returnCode;
2619
- }
2620
- }
2621
- }
2622
- return $failureCodes;
2623
- }
2624
-
2625
- /**
2626
- * Try executing supplied cwebp for PHP_OS.
2627
- *
2628
- * @param boolean $useNice Whether to use nice
2629
- * @param string $commandOptions for the exec call
2630
- * @param array $failureCodesForCommonSystemPaths Return codes from the other attempt
2631
- * (in order to produce short error message)
2632
- *
2633
- * @return string Error message if failure, empty string if successful
2634
*/
2635
- private function trySuppliedBinaryForOS($useNice, $commandOptions, $failureCodesForCommonSystemPaths)
2636
{
2637
- $this->logLn('Trying to execute supplied binary for OS: ' . PHP_OS);
2638
2639
// Try supplied binary (if available for OS, and hash is correct)
2640
$options = $this->options;
2641
if (!isset(self::$suppliedBinariesInfo[PHP_OS])) {
2642
- return 'No supplied binaries found for OS:' . PHP_OS;
2643
}
2644
2645
$info = self::$suppliedBinariesInfo[PHP_OS];
2646
@@ -2649,14 +2604,13 @@ class Cwebp extends AbstractConverter
2649
2650
$binaryFile = __DIR__ . '/' . $options['rel-path-to-precompiled-binaries'] . '/' . $file;
2651
2652
-
2653
// The file should exist, but may have been removed manually.
2654
if (!file_exists($binaryFile)) {
2655
- return 'Supplied binary not found! It ought to be here:' . $binaryFile;
2656
}
2657
2658
// File exists, now generate its hash
2659
-
2660
// hash_file() is normally available, but it is not always
2661
// - https://stackoverflow.com/questions/17382712/php-5-3-20-undefined-function-hash
2662
// If available, validate that hash is correct.
@@ -2665,92 +2619,204 @@ class Cwebp extends AbstractConverter
2665
$binaryHash = hash_file('sha256', $binaryFile);
2666
2667
if ($binaryHash != $hash) {
2668
- return 'Binary checksum of supplied binary is invalid! ' .
2669
'Did you transfer with FTP, but not in binary mode? ' .
2670
'File:' . $binaryFile . '. ' .
2671
'Expected checksum: ' . $hash . '. ' .
2672
- 'Actual checksum:' . $binaryHash . '.';
2673
}
2674
}
2675
2676
- $returnCode = $this->executeBinary($binaryFile, $commandOptions, $useNice);
2677
- if ($returnCode == 0) {
2678
- // yay!
2679
- $this->logLn('success!');
2680
- return '';
2681
}
2682
2683
- $errorMsg = 'Tried executing supplied binary for ' . PHP_OS . ', ' .
2684
- ($options['try-common-system-paths'] ? 'but that failed too' : 'but failed');
2685
2686
2687
- if (($options['try-common-system-paths']) && (count($failureCodesForCommonSystemPaths) > 0)) {
2688
- // check if it was the same error
2689
- // if it was, simply refer to that with "(same problem)"
2690
- $majorFailCode = 0;
2691
- if (count($failureCodesForCommonSystemPaths) == 1) {
2692
- $majorFailCode = $failureCodesForCommonSystemPaths[0];
2693
} else {
2694
- $failureCodesBesides127 = array_values(array_diff($failureCodesForCommonSystemPaths, [127]));
2695
- if (count($failureCodesBesides127) == 1) {
2696
- $majorFailCode = $failureCodesBesides127[0];
2697
- } else {
2698
- // it cannot be summarized into a single code
2699
}
2700
}
2701
- if ($majorFailCode != 0) {
2702
- $errorMsg .= ' (same problem)';
2703
- return $errorMsg;
2704
}
2705
}
2706
2707
- if ($returnCode > 128) {
2708
- $errorMsg .= '. The binary did not work (exit code: ' . $returnCode . '). ' .
2709
- 'Check out https://github.com/rosell-dk/webp-convert/issues/92';
2710
} else {
2711
- switch ($returnCode) {
2712
- case 0:
2713
- // success!
2714
- break;
2715
- case 126:
2716
- $errorMsg .= ': Permission denied. The user that the command was run' .
2717
- ' with (' . shell_exec('whoami') . ') does not have permission to ' .
2718
- 'execute that binary.';
2719
- break;
2720
- case 127:
2721
- $errorMsg .= '. The binary was not found! ' .
2722
- 'It ought to be here: ' . $binaryFile;
2723
- break;
2724
- default:
2725
- $errorMsg .= ' (exit code:' . $returnCode . ').';
2726
- }
2727
}
2728
- return $errorMsg;
2729
}
2730
2731
protected function doActualConvert()
2732
{
2733
- $errorMsg = '';
2734
- $options = $this->options;
2735
- $useNice = (($options['use-nice']) && self::hasNiceSupport());
2736
2737
- $commandOptions = $this->createCommandLineOptions();
2738
2739
- // Try all common paths that exists
2740
- $success = false;
2741
2742
- $failureCodes = [];
2743
2744
- if ($options['try-common-system-paths']) {
2745
- $failureCodes = $this->tryCommonSystemPaths($useNice, $commandOptions);
2746
- $success = (count($failureCodes) == 0);
2747
- $errorMsg = $this->composeErrorMessageForCommonSystemPathsFailures($failureCodes);
2748
}
2749
2750
- if (!$success && $options['try-supplied-binary-for-os']) {
2751
- $errorMsg2 = $this->trySuppliedBinaryForOS($useNice, $commandOptions, $failureCodes);
2752
- $errorMsg .= $errorMsg2;
2753
- $success = ($errorMsg2 == '');
2754
}
2755
2756
// cwebp sets file permissions to 664 but instead ..
@@ -2765,10 +2831,8 @@ class Cwebp extends AbstractConverter
2765
$permissions = $fileStatistics['mode'] & 0000666;
2766
chmod($this->destination, $permissions);
2767
}
2768
- }
2769
-
2770
- if (!$success) {
2771
- throw new SystemRequirementsNotMetException($errorMsg);
2772
}
2773
}
2774
}
@@ -2828,8 +2892,11 @@ class Ewww extends AbstractConverter
2828
if (!empty($this->options['api-key'])) {
2829
return $this->options['api-key'];
2830
}
2831
- if (!empty(getenv('EWWW_API_KEY'))) {
2832
- return getenv('EWWW_API_KEY');
2833
}
2834
return false;
2835
}
@@ -3811,11 +3878,13 @@ class GraphicsMagick extends AbstractConverter
3811
3812
private function getPath()
3813
{
3814
- if (empty(getenv('GRAPHICSMAGICK_PATH'))) {
3815
- return 'gm';
3816
- } else {
3817
- return getenv('GRAPHICSMAGICK_PATH');
3818
}
3819
}
3820
3821
public function isInstalled()
@@ -3983,16 +4052,13 @@ class ImageMagick extends AbstractConverter
3983
3984
private function getPath()
3985
{
3986
- // Should we use "magick" or "convert" command?
3987
- // It seems they do the same. But which is best supported? Which is mostly available (whitelisted)?
3988
- // Should we perhaps try both?
3989
- // For now, we just go with "convert"
3990
-
3991
- if (!empty(getenv('IMAGEMAGICK_PATH'))) {
3992
- return getenv('IMAGEMAGICK_PATH');
3993
- } else {
3994
- return 'convert';
3995
}
3996
}
3997
3998
private function getVersion()
@@ -4550,11 +4616,11 @@ class Stack extends AbstractConverter
4550
$this->ln();
4551
$this->logLn('Stack failed in ' . round((microtime(true) - $beginTimeStack) * 1000) . ' ms');
4552
4553
if ($anyRuntimeErrors) {
4554
// At least one converter failed
4555
throw new ConversionFailedException(
4556
- 'None of the converters in the stack could convert the image. ' .
4557
- 'At least one failed, even though its requirements seemed to be met.'
4558
);
4559
} else {
4560
// All converters threw a SystemRequirementsNotMetException
@@ -4892,8 +4958,11 @@ class Wpc extends AbstractConverter
4892
return $this->options['api-key'];
4893
}
4894
}
4895
- if (!empty(getenv('WPC_API_KEY'))) {
4896
- return getenv('WPC_API_KEY');
4897
}
4898
return '';
4899
}
@@ -4908,8 +4977,11 @@ class Wpc extends AbstractConverter
4908
if (!empty($this->options['api-url'])) {
4909
return $this->options['api-url'];
4910
}
4911
- if (!empty(getenv('WPC_API_URL'))) {
4912
- return getenv('WPC_API_URL');
4913
}
4914
return '';
4915
}
@@ -5860,10 +5932,7 @@ class Report
5860
$options['log-call-arguments'] = true;
5861
WebPConvert::convert($source, $destination, $options, $echoLogger);
5862
} catch (\Exception $e) {
5863
- $success = false;
5864
-
5865
$msg = $e->getMessage();
5866
-
5867
echo '<b>' . $msg . '</b>';
5868
5869
//echo '<p>Rethrowing exception for your convenience</p>';
461
if (isset($trace['file']) && isset($trace['line'])) {
462
$this->logLn(
463
$trace['file'] . ':' . $trace['line']
464
+ );
465
}
466
}
467
throw $e;
518
public function getMimeTypeOfSource()
519
{
520
if (!isset($this->sourceMimeType)) {
521
+ // PS: Scrutinizer complains that ImageMimeTypeGuesser::lenientGuess could also return a boolean
522
+ // but this is not true! - it returns string|false|null, just as this method does.
523
$this->sourceMimeType = ImageMimeTypeGuesser::lenientGuess($this->source);
524
}
525
return $this->sourceMimeType;
2163
abstract public function getOptions();
2164
abstract protected function setOption($optionName, $optionValue);
2165
abstract protected function logLn($msg, $style = '');
2166
+ abstract protected function log($msg, $style = '');
2167
abstract protected function ln();
2168
+ abstract protected function logReduction($source, $destination);
2169
2170
public function supportsLossless()
2171
{
2363
// OS-specific binaries included in this library, along with hashes
2364
// If other binaries are going to be added, notice that the first argument is what PHP_OS returns.
2365
// (possible values, see here: https://stackoverflow.com/questions/738823/possible-values-for-php-os)
2366
+ // Got the precompiled binaries here: https://developers.google.com/speed/webp/docs/precompiled
2367
private static $suppliedBinariesInfo = [
2368
'WINNT' => [ 'cwebp.exe', '49e9cb98db30bfa27936933e6fd94d407e0386802cb192800d9fd824f6476873'],
2369
'Darwin' => [ 'cwebp-mac12', 'a06a3ee436e375c89dbc1b0b2e8bd7729a55139ae072ed3f7bd2e07de0ebb379'],
2370
'SunOS' => [ 'cwebp-sol', '1febaffbb18e52dc2c524cda9eefd00c6db95bc388732868999c0f48deb73b4f'],
2371
'FreeBSD' => [ 'cwebp-fbsd', 'e5cbea11c97fadffe221fdf57c093c19af2737e4bbd2cb3cd5e908de64286573'],
2372
+ 'Linux' => [ 'cwebp-linux2', 'd6142e9da2f1cab541de10a31527c597225fff5644e66e31d62bb391c41bfbf4'] // 1.0.2
2373
+
2374
];
2375
2376
public function checkOperationality()
2389
2390
private function executeBinary($binary, $commandOptions, $useNice)
2391
{
2392
+ //$version = $this->detectVersion($binary);
2393
+
2394
$command = ($useNice ? 'nice ' : '') . $binary . ' ' . $commandOptions;
2395
2396
//$logger->logLn('command options:' . $commandOptions);
2397
+ $this->logLn('Trying to convert by executing the following command:');
2398
+ $this->logLn($command);
2399
exec($command, $output, $returnCode);
2400
$this->logExecOutput($output);
2401
/*
2449
}
2450
2451
/**
2452
+ * Build command line options for a given version of cwebp.
2453
+ *
2454
+ * The "-near_lossless" param is not supported on older versions of cwebp, so skip on those.
2455
*
2456
+ * @param string $version Version of cwebp.
2457
* @return string
2458
*/
2459
+ private function createCommandLineOptions($version)
2460
{
2461
+
2462
+ $this->logLn('Creating command line options for version: ' . $version);
2463
+
2464
+ // we only need two decimal places for version.
2465
+ // convert to number to make it easier to compare
2466
+ $version = preg_match('#^\d+\.\d+#', $version, $matches);
2467
+ $versionNum = 0;
2468
+ if (isset($matches[0])) {
2469
+ $versionNum = floatval($matches[0]);
2470
+ } else {
2471
+ $this->logLn(
2472
+ 'Could not extract version number from the following version string: ' . $version,
2473
+ 'bold'
2474
+ );
2475
+ }
2476
+
2477
+ //$this->logLn('version:' . strval($versionNum));
2478
+
2479
$options = $this->options;
2480
2481
$cmdOptions = [];
2482
2483
// Metadata (all, exif, icc, xmp or none (default))
2484
// Comma-separated list of existing metadata to copy from input to output
2485
+ if ($versionNum >= 0.3) {
2486
+ $cmdOptions[] = '-metadata ' . $options['metadata'];
2487
+ }
2488
2489
// preset. Appears first in the list as recommended in the docs
2490
if (!is_null($options['preset'])) {
2516
2517
// Losless PNG conversion
2518
if ($options['encoding'] == 'lossless') {
2519
+ // No need to add -lossless when near-lossless is used (on version >= 0.5)
2520
+ if (($options['near-lossless'] === 100) || ($versionNum < 0.5)) {
2521
$cmdOptions[] = '-lossless';
2522
}
2523
}
2524
2525
// Near-lossles
2526
if ($options['near-lossless'] !== 100) {
2527
+ if ($versionNum < 0.5) {
2528
+ $this->logLn(
2529
+ 'The near-lossless option is not supported on this (rather old) version of cwebp' .
2530
+ '- skipping it.',
2531
+ 'italic'
2532
+ );
2533
+ } else {
2534
+ // We only let near_lossless have effect when encoding is set to "lossless"
2535
+ // otherwise encoding=auto would not work as expected
2536
+
2537
+ if ($options['encoding'] == 'lossless') {
2538
+ $cmdOptions[] ='-near_lossless ' . $options['near-lossless'];
2539
+ } else {
2540
+ $this->logLn(
2541
+ 'The near-lossless option ignored for lossy'
2542
+ );
2543
+ }
2544
}
2545
}
2546
2575
$cmdOptions[] = '2>&1';
2576
2577
$commandOptions = implode(' ', $cmdOptions);
2578
+ //$this->logLn('command line options:' . $commandOptions);
2579
2580
return $commandOptions;
2581
}
2582
2583
/**
2584
+ * Get path for supplied binary for current OS - and validate hash.
2585
*
2586
+ * @return string|false False if something is wrong, otherwise the path.
2587
*/
2588
+ private function getSuppliedBinaryPathForOS()
2589
{
2590
+ $this->log('Checking if we have a supplied binary for OS: ' . PHP_OS . '... ');
2591
2592
// Try supplied binary (if available for OS, and hash is correct)
2593
$options = $this->options;
2594
if (!isset(self::$suppliedBinariesInfo[PHP_OS])) {
2595
+ $this->logLn('No we dont - not for that OS');
2596
+ return false;
2597
}
2598
+ $this->logLn('We do.');
2599
2600
$info = self::$suppliedBinariesInfo[PHP_OS];
2601
2604
2605
$binaryFile = __DIR__ . '/' . $options['rel-path-to-precompiled-binaries'] . '/' . $file;
2606
2607
// The file should exist, but may have been removed manually.
2608
if (!file_exists($binaryFile)) {
2609
+ $this->logLn('Supplied binary not found! It ought to be here:' . $binaryFile, 'italic');
2610
+ return false;
2611
}
2612
2613
// File exists, now generate its hash
2614
// hash_file() is normally available, but it is not always
2615
// - https://stackoverflow.com/questions/17382712/php-5-3-20-undefined-function-hash
2616
// If available, validate that hash is correct.
2619
$binaryHash = hash_file('sha256', $binaryFile);
2620
2621
if ($binaryHash != $hash) {
2622
+ $this->logLn(
2623
+ 'Binary checksum of supplied binary is invalid! ' .
2624
'Did you transfer with FTP, but not in binary mode? ' .
2625
'File:' . $binaryFile . '. ' .
2626
'Expected checksum: ' . $hash . '. ' .
2627
+ 'Actual checksum:' . $binaryHash . '.',
2628
+ 'bold'
2629
+ );
2630
}
2631
}
2632
+ return $binaryFile;
2633
+ }
2634
2635
+ private function discoverBinaries()
2636
+ {
2637
+ $this->logLn('Locating cwebp binaries');
2638
+
2639
+ if (defined('WEBPCONVERT_CWEBP_PATH')) {
2640
+ $this->logLn('WEBPCONVERT_CWEBP_PATH was defined, so using that path and ignoring any other');
2641
+ //$this->logLn('Value: "' . getenv('WEBPCONVERT_CWEBP_PATH') . '"');
2642
+ return [constant('WEBPCONVERT_CWEBP_PATH')];
2643
+ }
2644
+ if (!empty(getenv('WEBPCONVERT_CWEBP_PATH'))) {
2645
+ $this->logLn(
2646
+ 'WEBPCONVERT_CWEBP_PATH environment variable was set, so using that path and ignoring any other'
2647
+ );
2648
+ //$this->logLn('Value: "' . getenv('WEBPCONVERT_CWEBP_PATH') . '"');
2649
+ return [getenv('WEBPCONVERT_CWEBP_PATH')];
2650
}
2651
2652
+ $binaries = [];
2653
+ if ($this->options['try-common-system-paths']) {
2654
+ foreach (self::$cwebpDefaultPaths as $binary) {
2655
+ if (@file_exists($binary)) {
2656
+ $binaries[] = $binary;
2657
+ }
2658
+ }
2659
+ if (count($binaries) == 0) {
2660
+ $this->logLn('No cwebp binaries where located in common system locations');
2661
+ } else {
2662
+ $this->logLn(strval(count($binaries)) . ' cwebp binaries found in common system locations');
2663
+ }
2664
+ }
2665
+ // TODO: exec('whereis cwebp');
2666
+ if ($this->options['try-supplied-binary-for-os']) {
2667
+ $suppliedBinary = $this->getSuppliedBinaryPathForOS();
2668
+ if ($suppliedBinary !== false) {
2669
+ $binaries[] = $suppliedBinary;
2670
+ }
2671
+ } else {
2672
+ $this->logLn('Configured not to try the cwebp binary that comes bundled with webp-convert');
2673
+ }
2674
2675
+ if (count($binaries) == 0) {
2676
+ $this->logLn('No cwebp binaries to try!');
2677
+ }
2678
+ $this->logLn('A total of ' . strval(count($binaries)) . ' cwebp binaries where found');
2679
+ return $binaries;
2680
+ }
2681
2682
+ /**
2683
+ *
2684
+ * @return string|int Version string (ie "1.0.2") OR return code, in case of failure
2685
+ */
2686
+ private function detectVersion($binary)
2687
+ {
2688
+ //$this->logLn('Examining binary: ' . $binary);
2689
+ $command = $binary . ' -version';
2690
+ $this->log('Executing: ' . $command);
2691
+ exec($command, $output, $returnCode);
2692
+
2693
+ if ($returnCode == 0) {
2694
+ //$this->logLn('Success');
2695
+ if (isset($output[0])) {
2696
+ $this->logLn('. Result: version: ' . $output[0]);
2697
+ return $output[0];
2698
+ }
2699
+ } else {
2700
+ $this->logExecOutput($output);
2701
+ $this->logLn('');
2702
+ if ($returnCode == 127) {
2703
+ $this->logLn('Exec failed (the cwebp binary was not found at path: ' . $binary. ')');
2704
} else {
2705
+ $this->logLn(
2706
+ 'Exec failed (return code: ' . $returnCode . ')'
2707
+ );
2708
+ if ($returnCode == 126) {
2709
+ $this->logLn(
2710
+ 'PS: Return code 126 means "Permission denied". The user that the command was run with does ' .
2711
+ 'not have permission to execute that binary.'
2712
+ );
2713
+ // TODO: further info: shell_exec('whoami')
2714
}
2715
}
2716
+ return $returnCode;
2717
+ }
2718
+ }
2719
+
2720
+ /**
2721
+ * Check versions for binaries, and return array (indexed by the binary, value being the version of the binary).
2722
+ *
2723
+ * @return array
2724
+ */
2725
+ private function detectVersions($binaries)
2726
+ {
2727
+ $binariesWithVersions = [];
2728
+ $binariesWithFailCodes = [];
2729
+
2730
+ $this->logLn(
2731
+ 'Detecting versions of the cwebp binaries found (and verifying that they can be executed in the process)'
2732
+ );
2733
+ foreach ($binaries as $binary) {
2734
+ $versionStringOrFailCode = $this->detectVersion($binary);
2735
+ // $this->logLn($binary . ': ' . $versionString);
2736
+ if (gettype($versionStringOrFailCode) == 'string') {
2737
+ $binariesWithVersions[$binary] = $versionStringOrFailCode;
2738
+ } else {
2739
+ $binariesWithFailCodes[$binary] = $versionStringOrFailCode;
2740
}
2741
}
2742
+ return ['detected' => $binariesWithVersions, 'failed' => $binariesWithFailCodes];
2743
+ }
2744
+
2745
+ /**
2746
+ * @return boolean success or not.
2747
+ */
2748
+ private function tryBinary($binary, $version, $useNice)
2749
+ {
2750
2751
+ //$this->logLn('Trying binary: ' . $binary);
2752
+ $commandOptions = $this->createCommandLineOptions($version);
2753
+
2754
+ $returnCode = $this->executeBinary($binary, $commandOptions, $useNice);
2755
+ if ($returnCode == 0) {
2756
+ $this->logLn('Success');
2757
+ return true;
2758
} else {
2759
+ $this->logLn(
2760
+ 'Exec failed (return code: ' . $returnCode . ')'
2761
+ );
2762
+ return false;
2763
}
2764
}
2765
2766
protected function doActualConvert()
2767
{
2768
+ $binaries = $this->discoverBinaries();
2769
2770
+ if (count($binaries) == 0) {
2771
+ throw new SystemRequirementsNotMetException(
2772
+ 'No cwebp binaries located. Check the conversion log for details.'
2773
+ );
2774
+ }
2775
2776
+ $versions = $this->detectVersions($binaries);
2777
+ if (count($versions['detected']) == 0) {
2778
+ //$this->logLn('None of the cwebp files located can be executed.');
2779
+ if (count($binaries) == 1) {
2780
+ $errorMsg = 'The cwebp file found cannot be can be executed.';
2781
+ } else {
2782
+ $errorMsg = 'None of the cwebp files located can be executed.';
2783
+ }
2784
+ $uniqueFailCodes = array_unique(array_values($versions['failed']));
2785
+ if (count($uniqueFailCodes) == 1) {
2786
+ $errorMsg .= ' ' . (count($binaries) == 1 ? 'It' : 'All') .
2787
+ ' failed with return code ' . $uniqueFailCodes[0];
2788
+ if ($uniqueFailCodes[0] == 126) {
2789
+ $errorMsg .= ' (permission denied)';
2790
+ }
2791
+ } else {
2792
+ $errorMsg .= ' Failure codes : ' . implode(', ', $uniqueFailCodes);
2793
+ }
2794
+
2795
+ throw new SystemRequirementsNotMetException($errorMsg);
2796
+ }
2797
2798
+ $binaryVersions = $versions['detected'];
2799
2800
+ if (count($binaries) > 1) {
2801
+ $this->logLn(
2802
+ 'Trying executing the cwebs found until success. Starting with the ones with highest version number.'
2803
+ );
2804
}
2805
+ //$this->logLn('binary versions: ' . print_r($binaryVersions, true));
2806
+
2807
+ // Sort binaries so those with highest numbers comes first
2808
+ arsort($binaryVersions);
2809
2810
+ //$this->logLn('binary versions (ordered by version): ' . print_r($binaryVersions, true));
2811
+
2812
+ $useNice = (($this->options['use-nice']) && self::hasNiceSupport());
2813
+
2814
+ $success = false;
2815
+ foreach ($binaryVersions as $binary => $version) {
2816
+ if ($this->tryBinary($binary, $version, $useNice)) {
2817
+ $success = true;
2818
+ break;
2819
+ }
2820
}
2821
2822
// cwebp sets file permissions to 664 but instead ..
2831
$permissions = $fileStatistics['mode'] & 0000666;
2832
chmod($this->destination, $permissions);
2833
}
2834
+ } else {
2835
+ throw new SystemRequirementsNotMetException('Failed converting. Check the conversion log for details.');
2836
}
2837
}
2838
}
2892
if (!empty($this->options['api-key'])) {
2893
return $this->options['api-key'];
2894
}
2895
+ if (defined('WEBPCONVERT_EWWW_API_KEY')) {
2896
+ return constant('WEBPCONVERT_EWWW_API_KEY');
2897
+ }
2898
+ if (!empty(getenv('WEBPCONVERT_EWWW_API_KEY'))) {
2899
+ return getenv('WEBPCONVERT_EWWW_API_KEY');
2900
}
2901
return false;
2902
}
3878
3879
private function getPath()
3880
{
3881
+ if (defined('WEBPCONVERT_GRAPHICSMAGICK_PATH')) {
3882
+ return constant('WEBPCONVERT_GRAPHICSMAGICK_PATH');
3883
+ }
3884
+ if (!empty(getenv('WEBPCONVERT_GRAPHICSMAGICK_PATH'))) {
3885
+ return getenv('WEBPCONVERT_GRAPHICSMAGICK_PATH');
3886
}
3887
+ return 'gm';
3888
}
3889
3890
public function isInstalled()
4052
4053
private function getPath()
4054
{
4055
+ if (defined('WEBPCONVERT_IMAGEMAGICK_PATH')) {
4056
+ return constant('WEBPCONVERT_IMAGEMAGICK_PATH');
4057
}
4058
+ if (!empty(getenv('WEBPCONVERT_IMAGEMAGICK_PATH'))) {
4059
+ return getenv('WEBPCONVERT_IMAGEMAGICK_PATH');
4060
+ }
4061
+ return 'convert';
4062
}
4063
4064
private function getVersion()
4616
$this->ln();
4617
$this->logLn('Stack failed in ' . round((microtime(true) - $beginTimeStack) * 1000) . ' ms');
4618
4619
+ // Hm, Scrutinizer complains that $anyRuntimeErrors is always false. But that is not true!
4620
if ($anyRuntimeErrors) {
4621
// At least one converter failed
4622
throw new ConversionFailedException(
4623
+ 'None of the converters in the stack could convert the image.'
4624
);
4625
} else {
4626
// All converters threw a SystemRequirementsNotMetException
4958
return $this->options['api-key'];
4959
}
4960
}
4961
+ if (defined('WEBPCONVERT_WPC_API_KEY')) {
4962
+ return constant('WEBPCONVERT_WPC_API_KEY');
4963
+ }
4964
+ if (!empty(getenv('WEBPCONVERT_WPC_API_KEY'))) {
4965
+ return getenv('WEBPCONVERT_WPC_API_KEY');
4966
}
4967
return '';
4968
}
4977
if (!empty($this->options['api-url'])) {
4978
return $this->options['api-url'];
4979
}
4980
+ if (defined('WEBPCONVERT_WPC_API_URL')) {
4981
+ return constant('WEBPCONVERT_WPC_API_URL');
4982
+ }
4983
+ if (!empty(getenv('WEBPCONVERT_WPC_API_URL'))) {
4984
+ return getenv('WEBPCONVERT_WPC_API_URL');
4985
}
4986
return '';
4987
}
5932
$options['log-call-arguments'] = true;
5933
WebPConvert::convert($source, $destination, $options, $echoLogger);
5934
} catch (\Exception $e) {
5935
$msg = $e->getMessage();
5936
echo '<b>' . $msg . '</b>';
5937
5938
//echo '<p>Rethrowing exception for your convenience</p>';
vendor/rosell-dk/webp-convert/src-build/webp-on-demand-2.inc CHANGED
@@ -461,7 +461,7 @@ abstract class AbstractConverter
461
if (isset($trace['file']) && isset($trace['line'])) {
462
$this->logLn(
463
$trace['file'] . ':' . $trace['line']
464
- );
465
}
466
}
467
throw $e;
@@ -518,6 +518,8 @@ abstract class AbstractConverter
518
public function getMimeTypeOfSource()
519
{
520
if (!isset($this->sourceMimeType)) {
521
$this->sourceMimeType = ImageMimeTypeGuesser::lenientGuess($this->source);
522
}
523
return $this->sourceMimeType;
@@ -2083,7 +2085,9 @@ trait EncodingAutoTrait
2083
abstract public function getOptions();
2084
abstract protected function setOption($optionName, $optionValue);
2085
abstract protected function logLn($msg, $style = '');
2086
abstract protected function ln();
2087
2088
public function supportsLossless()
2089
{
@@ -2281,12 +2285,14 @@ class Cwebp extends AbstractConverter
2281
// OS-specific binaries included in this library, along with hashes
2282
// If other binaries are going to be added, notice that the first argument is what PHP_OS returns.
2283
// (possible values, see here: https://stackoverflow.com/questions/738823/possible-values-for-php-os)
2284
private static $suppliedBinariesInfo = [
2285
'WINNT' => [ 'cwebp.exe', '49e9cb98db30bfa27936933e6fd94d407e0386802cb192800d9fd824f6476873'],
2286
'Darwin' => [ 'cwebp-mac12', 'a06a3ee436e375c89dbc1b0b2e8bd7729a55139ae072ed3f7bd2e07de0ebb379'],
2287
'SunOS' => [ 'cwebp-sol', '1febaffbb18e52dc2c524cda9eefd00c6db95bc388732868999c0f48deb73b4f'],
2288
'FreeBSD' => [ 'cwebp-fbsd', 'e5cbea11c97fadffe221fdf57c093c19af2737e4bbd2cb3cd5e908de64286573'],
2289
- 'Linux' => [ 'cwebp-linux', '916623e5e9183237c851374d969aebdb96e0edc0692ab7937b95ea67dc3b2568']
2290
];
2291
2292
public function checkOperationality()
@@ -2305,10 +2311,13 @@ class Cwebp extends AbstractConverter
2305
2306
private function executeBinary($binary, $commandOptions, $useNice)
2307
{
2308
$command = ($useNice ? 'nice ' : '') . $binary . ' ' . $commandOptions;
2309
2310
//$logger->logLn('command options:' . $commandOptions);
2311
- //$logger->logLn('Trying to execute binary:' . $binary);
2312
exec($command, $output, $returnCode);
2313
$this->logExecOutput($output);
2314
/*
@@ -2362,19 +2371,42 @@ class Cwebp extends AbstractConverter
2362
}
2363
2364
/**
2365
- * Build command line options
2366
*
2367
* @return string
2368
*/
2369
- private function createCommandLineOptions()
2370
{
2371
$options = $this->options;
2372
2373
$cmdOptions = [];
2374
2375
// Metadata (all, exif, icc, xmp or none (default))
2376
// Comma-separated list of existing metadata to copy from input to output
2377
- $cmdOptions[] = '-metadata ' . $options['metadata'];
2378
2379
// preset. Appears first in the list as recommended in the docs
2380
if (!is_null($options['preset'])) {
@@ -2406,18 +2438,31 @@ class Cwebp extends AbstractConverter
2406
2407
// Losless PNG conversion
2408
if ($options['encoding'] == 'lossless') {
2409
- // No need to add -lossless when near-lossless is used
2410
- if ($options['near-lossless'] === 100) {
2411
$cmdOptions[] = '-lossless';
2412
}
2413
}
2414
2415
// Near-lossles
2416
if ($options['near-lossless'] !== 100) {
2417
- // We only let near_lossless have effect when encoding is set to "lossless"
2418
- // otherwise encoding=auto would not work as expected
2419
- if ($options['encoding'] == 'lossless') {
2420
- $cmdOptions[] ='-near_lossless ' . $options['near-lossless'];
2421
}
2422
}
2423
@@ -2452,117 +2497,27 @@ class Cwebp extends AbstractConverter
2452
$cmdOptions[] = '2>&1';
2453
2454
$commandOptions = implode(' ', $cmdOptions);
2455
- $this->logLn('command line options:' . $commandOptions);
2456
2457
return $commandOptions;
2458
}
2459
2460
/**
2461
*
2462
- *
2463
- * @return string Error message if failure, empty string if successful
2464
- */
2465
- private function composeErrorMessageForCommonSystemPathsFailures($failureCodes)
2466
- {
2467
- if (count($failureCodes) == 1) {
2468
- switch ($failureCodes[0]) {
2469
- case 126:
2470
- return 'Permission denied. The user that the command was run with (' .
2471
- shell_exec('whoami') . ') does not have permission to execute any of the ' .
2472
- 'cweb binaries found in common system locations. ';
2473
- case 127:
2474
- return 'Found no cwebp binaries in any common system locations. ';
2475
- default:
2476
- return 'Tried executing cwebp binaries in common system locations. ' .
2477
- 'All failed (exit code: ' . $failureCodes[0] . '). ';
2478
- }
2479
- } else {
2480
- /**
2481
- * $failureCodesBesides127 is used to check first position ($failureCodesBesides127[0])
2482
- * however position can vary as index can be 1 or something else. array_values() would
2483
- * always start from 0.
2484
- */
2485
- $failureCodesBesides127 = array_values(array_diff($failureCodes, [127]));
2486
-
2487
- if (count($failureCodesBesides127) == 1) {
2488
- switch ($failureCodesBesides127[0]) {
2489
- case 126:
2490
- return 'Permission denied. The user that the command was run with (' .
2491
- shell_exec('whoami') . ') does not have permission to execute any of the cweb ' .
2492
- 'binaries found in common system locations. ';
2493
- break;
2494
- default:
2495
- return 'Tried executing cwebp binaries in common system locations. ' .
2496
- 'All failed (exit code: ' . $failureCodesBesides127[0] . '). ';
2497
- }
2498
- } else {
2499
- return 'None of the cwebp binaries in the common system locations could be executed ' .
2500
- '(mixed results - got the following exit codes: ' . implode(',', $failureCodes) . '). ';
2501
- }
2502
- }
2503
- }
2504
-
2505
- /**
2506
- * Try executing cwebp in common system paths
2507
- *
2508
- * @param boolean $useNice Whether to use nice
2509
- * @param string $commandOptions for the exec call
2510
- *
2511
- * @return array Unique failure codes in case of failure, empty array in case of success
2512
- */
2513
- private function tryCommonSystemPaths($useNice, $commandOptions)
2514
- {
2515
- $failureCodes = [];
2516
-
2517
- $paths = self::$cwebpDefaultPaths;
2518
-
2519
- if (!empty(getenv('CWEBP_PATH'))) {
2520
- array_unshift($paths, getenv('CWEBP_PATH'));
2521
- }
2522
-
2523
- // Loop through paths
2524
- foreach ($paths as $index => $binary) {
2525
- $returnCode = $this->executeBinary($binary, $commandOptions, $useNice);
2526
- if ($returnCode == 0) {
2527
- $this->logLn('Successfully executed binary: ' . $binary);
2528
- return [];
2529
- } else {
2530
- if ($returnCode == 127) {
2531
- $this->logLn(
2532
- 'Trying to execute binary: ' . $binary . '. Failed (not found)'
2533
- );
2534
- } else {
2535
- $this->logLn(
2536
- 'Trying to execute binary: ' . $binary . '. Failed (return code: ' . $returnCode . ')'
2537
- );
2538
- }
2539
- if (!in_array($returnCode, $failureCodes)) {
2540
- $failureCodes[] = $returnCode;
2541
- }
2542
- }
2543
- }
2544
- return $failureCodes;
2545
- }
2546
-
2547
- /**
2548
- * Try executing supplied cwebp for PHP_OS.
2549
- *
2550
- * @param boolean $useNice Whether to use nice
2551
- * @param string $commandOptions for the exec call
2552
- * @param array $failureCodesForCommonSystemPaths Return codes from the other attempt
2553
- * (in order to produce short error message)
2554
- *
2555
- * @return string Error message if failure, empty string if successful
2556
*/
2557
- private function trySuppliedBinaryForOS($useNice, $commandOptions, $failureCodesForCommonSystemPaths)
2558
{
2559
- $this->logLn('Trying to execute supplied binary for OS: ' . PHP_OS);
2560
2561
// Try supplied binary (if available for OS, and hash is correct)
2562
$options = $this->options;
2563
if (!isset(self::$suppliedBinariesInfo[PHP_OS])) {
2564
- return 'No supplied binaries found for OS:' . PHP_OS;
2565
}
2566
2567
$info = self::$suppliedBinariesInfo[PHP_OS];
2568
@@ -2571,14 +2526,13 @@ class Cwebp extends AbstractConverter
2571
2572
$binaryFile = __DIR__ . '/' . $options['rel-path-to-precompiled-binaries'] . '/' . $file;
2573
2574
-
2575
// The file should exist, but may have been removed manually.
2576
if (!file_exists($binaryFile)) {
2577
- return 'Supplied binary not found! It ought to be here:' . $binaryFile;
2578
}
2579
2580
// File exists, now generate its hash
2581
-
2582
// hash_file() is normally available, but it is not always
2583
// - https://stackoverflow.com/questions/17382712/php-5-3-20-undefined-function-hash
2584
// If available, validate that hash is correct.
@@ -2587,92 +2541,204 @@ class Cwebp extends AbstractConverter
2587
$binaryHash = hash_file('sha256', $binaryFile);
2588
2589
if ($binaryHash != $hash) {
2590
- return 'Binary checksum of supplied binary is invalid! ' .
2591
'Did you transfer with FTP, but not in binary mode? ' .
2592
'File:' . $binaryFile . '. ' .
2593
'Expected checksum: ' . $hash . '. ' .
2594
- 'Actual checksum:' . $binaryHash . '.';
2595
}
2596
}
2597
2598
- $returnCode = $this->executeBinary($binaryFile, $commandOptions, $useNice);
2599
- if ($returnCode == 0) {
2600
- // yay!
2601
- $this->logLn('success!');
2602
- return '';
2603
}
2604
2605
- $errorMsg = 'Tried executing supplied binary for ' . PHP_OS . ', ' .
2606
- ($options['try-common-system-paths'] ? 'but that failed too' : 'but failed');
2607
2608
2609
- if (($options['try-common-system-paths']) && (count($failureCodesForCommonSystemPaths) > 0)) {
2610
- // check if it was the same error
2611
- // if it was, simply refer to that with "(same problem)"
2612
- $majorFailCode = 0;
2613
- if (count($failureCodesForCommonSystemPaths) == 1) {
2614
- $majorFailCode = $failureCodesForCommonSystemPaths[0];
2615
} else {
2616
- $failureCodesBesides127 = array_values(array_diff($failureCodesForCommonSystemPaths, [127]));
2617
- if (count($failureCodesBesides127) == 1) {
2618
- $majorFailCode = $failureCodesBesides127[0];
2619
- } else {
2620
- // it cannot be summarized into a single code
2621
}
2622
}
2623
- if ($majorFailCode != 0) {
2624
- $errorMsg .= ' (same problem)';
2625
- return $errorMsg;
2626
}
2627
}
2628
2629
- if ($returnCode > 128) {
2630
- $errorMsg .= '. The binary did not work (exit code: ' . $returnCode . '). ' .
2631
- 'Check out https://github.com/rosell-dk/webp-convert/issues/92';
2632
} else {
2633
- switch ($returnCode) {
2634
- case 0:
2635
- // success!
2636
- break;
2637
- case 126:
2638
- $errorMsg .= ': Permission denied. The user that the command was run' .
2639
- ' with (' . shell_exec('whoami') . ') does not have permission to ' .
2640
- 'execute that binary.';
2641
- break;
2642
- case 127:
2643
- $errorMsg .= '. The binary was not found! ' .
2644
- 'It ought to be here: ' . $binaryFile;
2645
- break;
2646
- default:
2647
- $errorMsg .= ' (exit code:' . $returnCode . ').';
2648
- }
2649
}
2650
- return $errorMsg;
2651
}
2652
2653
protected function doActualConvert()
2654
{
2655
- $errorMsg = '';
2656
- $options = $this->options;
2657
- $useNice = (($options['use-nice']) && self::hasNiceSupport());
2658
2659
- $commandOptions = $this->createCommandLineOptions();
2660
2661
- // Try all common paths that exists
2662
- $success = false;
2663
2664
- $failureCodes = [];
2665
2666
- if ($options['try-common-system-paths']) {
2667
- $failureCodes = $this->tryCommonSystemPaths($useNice, $commandOptions);
2668
- $success = (count($failureCodes) == 0);
2669
- $errorMsg = $this->composeErrorMessageForCommonSystemPathsFailures($failureCodes);
2670
}
2671
2672
- if (!$success && $options['try-supplied-binary-for-os']) {
2673
- $errorMsg2 = $this->trySuppliedBinaryForOS($useNice, $commandOptions, $failureCodes);
2674
- $errorMsg .= $errorMsg2;
2675
- $success = ($errorMsg2 == '');
2676
}
2677
2678
// cwebp sets file permissions to 664 but instead ..
@@ -2687,10 +2753,8 @@ class Cwebp extends AbstractConverter
2687
$permissions = $fileStatistics['mode'] & 0000666;
2688
chmod($this->destination, $permissions);
2689
}
2690
- }
2691
-
2692
- if (!$success) {
2693
- throw new SystemRequirementsNotMetException($errorMsg);
2694
}
2695
}
2696
}
@@ -2750,8 +2814,11 @@ class Ewww extends AbstractConverter
2750
if (!empty($this->options['api-key'])) {
2751
return $this->options['api-key'];
2752
}
2753
- if (!empty(getenv('EWWW_API_KEY'))) {
2754
- return getenv('EWWW_API_KEY');
2755
}
2756
return false;
2757
}
@@ -3733,11 +3800,13 @@ class GraphicsMagick extends AbstractConverter
3733
3734
private function getPath()
3735
{
3736
- if (empty(getenv('GRAPHICSMAGICK_PATH'))) {
3737
- return 'gm';
3738
- } else {
3739
- return getenv('GRAPHICSMAGICK_PATH');
3740
}
3741
}
3742
3743
public function isInstalled()
@@ -3905,16 +3974,13 @@ class ImageMagick extends AbstractConverter
3905
3906
private function getPath()
3907
{
3908
- // Should we use "magick" or "convert" command?
3909
- // It seems they do the same. But which is best supported? Which is mostly available (whitelisted)?
3910
- // Should we perhaps try both?
3911
- // For now, we just go with "convert"
3912
-
3913
- if (!empty(getenv('IMAGEMAGICK_PATH'))) {
3914
- return getenv('IMAGEMAGICK_PATH');
3915
- } else {
3916
- return 'convert';
3917
}
3918
}
3919
3920
private function getVersion()
@@ -4472,11 +4538,11 @@ class Stack extends AbstractConverter
4472
$this->ln();
4473
$this->logLn('Stack failed in ' . round((microtime(true) - $beginTimeStack) * 1000) . ' ms');
4474
4475
if ($anyRuntimeErrors) {
4476
// At least one converter failed
4477
throw new ConversionFailedException(
4478
- 'None of the converters in the stack could convert the image. ' .
4479
- 'At least one failed, even though its requirements seemed to be met.'
4480
);
4481