mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-19 06:11:27 +02:00
adding support for pngquant
This commit is contained in:
@@ -21,6 +21,9 @@ if (!$no) {
|
||||
|
||||
echo "<strong>Checking path for postprocessing tools</strong>";
|
||||
|
||||
echo "<br>pngquant: ";
|
||||
system("which pngquant");
|
||||
|
||||
echo "<br>optipng: ";
|
||||
system("which optipng");
|
||||
|
||||
|
@@ -840,6 +840,9 @@ verbose("upscale = $upscale");
|
||||
* Get details for post processing
|
||||
*/
|
||||
$postProcessing = getConfig('postprocessing', array(
|
||||
'png_lossy' => false,
|
||||
'png_lossy_cmd' => '/usr/local/bin/pngquant --force --output',
|
||||
|
||||
'png_filter' => false,
|
||||
'png_filter_cmd' => '/usr/local/bin/optipng -q',
|
||||
|
||||
@@ -852,6 +855,15 @@ $postProcessing = getConfig('postprocessing', array(
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* lossy - Do lossy postprocessing, if available.
|
||||
*/
|
||||
$lossy = getDefined(array('lossy'), true, null);
|
||||
|
||||
verbose("lossy = $lossy");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* alias - Save resulting image to another alias name.
|
||||
* Password always apply, must be defined.
|
||||
@@ -970,7 +982,7 @@ if ($status) {
|
||||
$res = $cache->getStatusOfSubdir("srgb");
|
||||
$text .= "Cache srgb $res\n";
|
||||
|
||||
$res = $cache->getStatusOfSubdir($fasttrackCache);
|
||||
$res = $cache->getStatusOfSubdir($fastTrackCache);
|
||||
$text .= "Cache fasttrack $res\n";
|
||||
|
||||
$text .= "Alias path writable = " . is_writable($aliasPath) . "\n";
|
||||
@@ -987,6 +999,11 @@ if ($status) {
|
||||
$no = extension_loaded('gd') ? null : 'NOT';
|
||||
$text .= "Extension gd is $no loaded.<br>";
|
||||
|
||||
$text .= checkExternalCommand("PNG LOSSY", $postProcessing["png_lossy"], $postProcessing["png_lossy_cmd"]);
|
||||
$text .= checkExternalCommand("PNG FILTER", $postProcessing["png_filter"], $postProcessing["png_filter_cmd"]);
|
||||
$text .= checkExternalCommand("PNG DEFLATE", $postProcessing["png_deflate"], $postProcessing["png_deflate_cmd"]);
|
||||
$text .= checkExternalCommand("JPEG OPTIMIZE", $postProcessing["jpeg_optimize"], $postProcessing["jpeg_optimize_cmd"]);
|
||||
|
||||
if (!$no) {
|
||||
$text .= print_r(gd_info(), 1);
|
||||
}
|
||||
@@ -1055,6 +1072,7 @@ if (is_callable($hookBeforeCImage)) {
|
||||
|
||||
// Other
|
||||
'postProcessing' => $postProcessing,
|
||||
'lossy' => $lossy,
|
||||
));
|
||||
verbose(print_r($allConfig, 1));
|
||||
extract($allConfig);
|
||||
@@ -1139,6 +1157,9 @@ $img->log("Incoming arguments: " . print_r(verbose(), 1))
|
||||
// Output format
|
||||
'outputFormat' => $outputFormat,
|
||||
'dpr' => $dpr,
|
||||
|
||||
// Postprocessing using external tools
|
||||
'lossy' => $lossy,
|
||||
)
|
||||
)
|
||||
->loadImageDetails()
|
||||
|
BIN
webroot/img/duke.png
Normal file
BIN
webroot/img/duke.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 228 KiB |
@@ -41,7 +41,7 @@ return array(
|
||||
* mode: 'production'
|
||||
*/
|
||||
//'mode' => 'production',
|
||||
'mode' => 'development',
|
||||
//'mode' => 'development',
|
||||
//'mode' => 'strict',
|
||||
|
||||
|
||||
@@ -321,8 +321,16 @@ return array(
|
||||
* Post processing of images using external tools, set to true or false
|
||||
* and set command to be executed.
|
||||
*
|
||||
* The png_lossy can alos have a value of null which means that its
|
||||
* enabled but not used as default. Each image having the option
|
||||
* &lossy will be processed. This means one can individually choose
|
||||
* when to use the lossy processing.
|
||||
*
|
||||
* Default values.
|
||||
*
|
||||
* png_lossy: false
|
||||
* png_lossy_cmd: '/usr/local/bin/pngquant --force --output'
|
||||
*
|
||||
* png_filter: false
|
||||
* png_filter_cmd: '/usr/local/bin/optipng -q'
|
||||
*
|
||||
@@ -334,6 +342,9 @@ return array(
|
||||
*/
|
||||
/*
|
||||
'postprocessing' => array(
|
||||
'png_lossy' => false,
|
||||
'png_lossy_cmd' => '/usr/local/bin/pngquant --force --output',
|
||||
|
||||
'png_filter' => false,
|
||||
'png_filter_cmd' => '/usr/local/bin/optipng -q',
|
||||
|
||||
|
Reference in New Issue
Block a user