mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-01 22:00:31 +02:00
prepare to tag v0.7.16
This commit is contained in:
@@ -38,7 +38,7 @@ $config = array(
|
|||||||
|
|
||||||
|
|
||||||
// Version of cimage and img.php
|
// Version of cimage and img.php
|
||||||
define("CIMAGE_VERSION", "v0.7.15 (2016-08-09)");
|
define("CIMAGE_VERSION", "v0.7.16 (2016-08-09)");
|
||||||
|
|
||||||
// For CRemoteImage
|
// For CRemoteImage
|
||||||
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
|
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
|
||||||
@@ -217,6 +217,27 @@ function verbose($msg = null)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log when verbose mode, when used without argument it returns the result.
|
||||||
|
*
|
||||||
|
* @param string $msg to log.
|
||||||
|
*
|
||||||
|
* @return void or array.
|
||||||
|
*/
|
||||||
|
function checkExternalCommand($what, $enabled, $commandString)
|
||||||
|
{
|
||||||
|
$no = $enabled ? null : 'NOT';
|
||||||
|
$text = "Post processing $what is $no enabled.<br>";
|
||||||
|
|
||||||
|
list($command) = explode(" ", $commandString);
|
||||||
|
$no = is_executable($command) ? null : 'NOT';
|
||||||
|
$text .= "The command for $what is $no an executable.<br>";
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a image from a remote server using HTTP GET and If-Modified-Since.
|
* Get a image from a remote server using HTTP GET and If-Modified-Since.
|
||||||
*
|
*
|
||||||
@@ -1260,6 +1281,13 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do lossy output using external postprocessing tools.
|
||||||
|
*/
|
||||||
|
private $lossy = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verbose mode to print out a trace and display the created image
|
* Verbose mode to print out a trace and display the created image
|
||||||
*/
|
*/
|
||||||
@@ -1295,7 +1323,15 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to command for filter optimize, for example optipng or null.
|
* Path to command for lossy optimize, for example pngquant.
|
||||||
|
*/
|
||||||
|
private $pngLossy;
|
||||||
|
private $pngLossyCmd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to command for filter optimize, for example optipng.
|
||||||
*/
|
*/
|
||||||
private $pngFilter;
|
private $pngFilter;
|
||||||
private $pngFilterCmd;
|
private $pngFilterCmd;
|
||||||
@@ -1303,7 +1339,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to command for deflate optimize, for example pngout or null.
|
* Path to command for deflate optimize, for example pngout.
|
||||||
*/
|
*/
|
||||||
private $pngDeflate;
|
private $pngDeflate;
|
||||||
private $pngDeflateCmd;
|
private $pngDeflateCmd;
|
||||||
@@ -1932,6 +1968,9 @@ class CImage
|
|||||||
// Output format
|
// Output format
|
||||||
'outputFormat' => null,
|
'outputFormat' => null,
|
||||||
'dpr' => 1,
|
'dpr' => 1,
|
||||||
|
|
||||||
|
// Postprocessing using external tools
|
||||||
|
'lossy' => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert crop settings from string to array
|
// Convert crop settings from string to array
|
||||||
@@ -3450,6 +3489,14 @@ class CImage
|
|||||||
$this->jpegOptimizeCmd = null;
|
$this->jpegOptimizeCmd = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists("png_lossy", $options)
|
||||||
|
&& $options['png_lossy'] !== false) {
|
||||||
|
$this->pngLossy = $options['png_lossy'];
|
||||||
|
$this->pngLossyCmd = $options['png_lossy_cmd'];
|
||||||
|
} else {
|
||||||
|
$this->pngLossyCmd = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($options['png_filter']) && $options['png_filter']) {
|
if (isset($options['png_filter']) && $options['png_filter']) {
|
||||||
$this->pngFilterCmd = $options['png_filter_cmd'];
|
$this->pngFilterCmd = $options['png_filter_cmd'];
|
||||||
} else {
|
} else {
|
||||||
@@ -3551,6 +3598,24 @@ class CImage
|
|||||||
imagesavealpha($this->image, true);
|
imagesavealpha($this->image, true);
|
||||||
imagepng($this->image, $this->cacheFileName, $this->compress);
|
imagepng($this->image, $this->cacheFileName, $this->compress);
|
||||||
|
|
||||||
|
// Use external program to process lossy PNG, if defined
|
||||||
|
$lossyEnabled = $this->pngLossy === true;
|
||||||
|
$lossySoftEnabled = $this->pngLossy === null;
|
||||||
|
$lossyActiveEnabled = $this->lossy === true;
|
||||||
|
if ($lossyEnabled || ($lossySoftEnabled && $lossyActiveEnabled)) {
|
||||||
|
if ($this->verbose) {
|
||||||
|
clearstatcache();
|
||||||
|
$this->log("Lossy enabled: $lossyEnabled");
|
||||||
|
$this->log("Lossy soft enabled: $lossySoftEnabled");
|
||||||
|
$this->Log("Filesize before lossy optimize: " . filesize($this->cacheFileName) . " bytes.");
|
||||||
|
}
|
||||||
|
$res = array();
|
||||||
|
$cmd = $this->pngLossyCmd . " $this->cacheFileName $this->cacheFileName";
|
||||||
|
exec($cmd, $res);
|
||||||
|
$this->Log($cmd);
|
||||||
|
$this->Log($res);
|
||||||
|
}
|
||||||
|
|
||||||
// Use external program to filter PNG, if defined
|
// Use external program to filter PNG, if defined
|
||||||
if ($this->pngFilterCmd) {
|
if ($this->pngFilterCmd) {
|
||||||
if ($this->verbose) {
|
if ($this->verbose) {
|
||||||
@@ -5183,6 +5248,9 @@ verbose("upscale = $upscale");
|
|||||||
* Get details for post processing
|
* Get details for post processing
|
||||||
*/
|
*/
|
||||||
$postProcessing = getConfig('postprocessing', array(
|
$postProcessing = getConfig('postprocessing', array(
|
||||||
|
'png_lossy' => false,
|
||||||
|
'png_lossy_cmd' => '/usr/local/bin/pngquant --force --output',
|
||||||
|
|
||||||
'png_filter' => false,
|
'png_filter' => false,
|
||||||
'png_filter_cmd' => '/usr/local/bin/optipng -q',
|
'png_filter_cmd' => '/usr/local/bin/optipng -q',
|
||||||
|
|
||||||
@@ -5195,6 +5263,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.
|
* alias - Save resulting image to another alias name.
|
||||||
* Password always apply, must be defined.
|
* Password always apply, must be defined.
|
||||||
@@ -5313,7 +5390,7 @@ if ($status) {
|
|||||||
$res = $cache->getStatusOfSubdir("srgb");
|
$res = $cache->getStatusOfSubdir("srgb");
|
||||||
$text .= "Cache srgb $res\n";
|
$text .= "Cache srgb $res\n";
|
||||||
|
|
||||||
$res = $cache->getStatusOfSubdir($fasttrackCache);
|
$res = $cache->getStatusOfSubdir($fastTrackCache);
|
||||||
$text .= "Cache fasttrack $res\n";
|
$text .= "Cache fasttrack $res\n";
|
||||||
|
|
||||||
$text .= "Alias path writable = " . is_writable($aliasPath) . "\n";
|
$text .= "Alias path writable = " . is_writable($aliasPath) . "\n";
|
||||||
@@ -5330,6 +5407,11 @@ if ($status) {
|
|||||||
$no = extension_loaded('gd') ? null : 'NOT';
|
$no = extension_loaded('gd') ? null : 'NOT';
|
||||||
$text .= "Extension gd is $no loaded.<br>";
|
$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) {
|
if (!$no) {
|
||||||
$text .= print_r(gd_info(), 1);
|
$text .= print_r(gd_info(), 1);
|
||||||
}
|
}
|
||||||
@@ -5398,6 +5480,7 @@ if (is_callable($hookBeforeCImage)) {
|
|||||||
|
|
||||||
// Other
|
// Other
|
||||||
'postProcessing' => $postProcessing,
|
'postProcessing' => $postProcessing,
|
||||||
|
'lossy' => $lossy,
|
||||||
));
|
));
|
||||||
verbose(print_r($allConfig, 1));
|
verbose(print_r($allConfig, 1));
|
||||||
extract($allConfig);
|
extract($allConfig);
|
||||||
@@ -5482,6 +5565,9 @@ $img->log("Incoming arguments: " . print_r(verbose(), 1))
|
|||||||
// Output format
|
// Output format
|
||||||
'outputFormat' => $outputFormat,
|
'outputFormat' => $outputFormat,
|
||||||
'dpr' => $dpr,
|
'dpr' => $dpr,
|
||||||
|
|
||||||
|
// Postprocessing using external tools
|
||||||
|
'lossy' => $lossy,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->loadImageDetails()
|
->loadImageDetails()
|
||||||
|
@@ -38,7 +38,7 @@ $config = array(
|
|||||||
|
|
||||||
|
|
||||||
// Version of cimage and img.php
|
// Version of cimage and img.php
|
||||||
define("CIMAGE_VERSION", "v0.7.15 (2016-08-09)");
|
define("CIMAGE_VERSION", "v0.7.16 (2016-08-09)");
|
||||||
|
|
||||||
// For CRemoteImage
|
// For CRemoteImage
|
||||||
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
|
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
|
||||||
@@ -217,6 +217,27 @@ function verbose($msg = null)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log when verbose mode, when used without argument it returns the result.
|
||||||
|
*
|
||||||
|
* @param string $msg to log.
|
||||||
|
*
|
||||||
|
* @return void or array.
|
||||||
|
*/
|
||||||
|
function checkExternalCommand($what, $enabled, $commandString)
|
||||||
|
{
|
||||||
|
$no = $enabled ? null : 'NOT';
|
||||||
|
$text = "Post processing $what is $no enabled.<br>";
|
||||||
|
|
||||||
|
list($command) = explode(" ", $commandString);
|
||||||
|
$no = is_executable($command) ? null : 'NOT';
|
||||||
|
$text .= "The command for $what is $no an executable.<br>";
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a image from a remote server using HTTP GET and If-Modified-Since.
|
* Get a image from a remote server using HTTP GET and If-Modified-Since.
|
||||||
*
|
*
|
||||||
@@ -1260,6 +1281,13 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do lossy output using external postprocessing tools.
|
||||||
|
*/
|
||||||
|
private $lossy = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verbose mode to print out a trace and display the created image
|
* Verbose mode to print out a trace and display the created image
|
||||||
*/
|
*/
|
||||||
@@ -1295,7 +1323,15 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to command for filter optimize, for example optipng or null.
|
* Path to command for lossy optimize, for example pngquant.
|
||||||
|
*/
|
||||||
|
private $pngLossy;
|
||||||
|
private $pngLossyCmd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to command for filter optimize, for example optipng.
|
||||||
*/
|
*/
|
||||||
private $pngFilter;
|
private $pngFilter;
|
||||||
private $pngFilterCmd;
|
private $pngFilterCmd;
|
||||||
@@ -1303,7 +1339,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to command for deflate optimize, for example pngout or null.
|
* Path to command for deflate optimize, for example pngout.
|
||||||
*/
|
*/
|
||||||
private $pngDeflate;
|
private $pngDeflate;
|
||||||
private $pngDeflateCmd;
|
private $pngDeflateCmd;
|
||||||
@@ -1932,6 +1968,9 @@ class CImage
|
|||||||
// Output format
|
// Output format
|
||||||
'outputFormat' => null,
|
'outputFormat' => null,
|
||||||
'dpr' => 1,
|
'dpr' => 1,
|
||||||
|
|
||||||
|
// Postprocessing using external tools
|
||||||
|
'lossy' => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert crop settings from string to array
|
// Convert crop settings from string to array
|
||||||
@@ -3450,6 +3489,14 @@ class CImage
|
|||||||
$this->jpegOptimizeCmd = null;
|
$this->jpegOptimizeCmd = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists("png_lossy", $options)
|
||||||
|
&& $options['png_lossy'] !== false) {
|
||||||
|
$this->pngLossy = $options['png_lossy'];
|
||||||
|
$this->pngLossyCmd = $options['png_lossy_cmd'];
|
||||||
|
} else {
|
||||||
|
$this->pngLossyCmd = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($options['png_filter']) && $options['png_filter']) {
|
if (isset($options['png_filter']) && $options['png_filter']) {
|
||||||
$this->pngFilterCmd = $options['png_filter_cmd'];
|
$this->pngFilterCmd = $options['png_filter_cmd'];
|
||||||
} else {
|
} else {
|
||||||
@@ -3551,6 +3598,24 @@ class CImage
|
|||||||
imagesavealpha($this->image, true);
|
imagesavealpha($this->image, true);
|
||||||
imagepng($this->image, $this->cacheFileName, $this->compress);
|
imagepng($this->image, $this->cacheFileName, $this->compress);
|
||||||
|
|
||||||
|
// Use external program to process lossy PNG, if defined
|
||||||
|
$lossyEnabled = $this->pngLossy === true;
|
||||||
|
$lossySoftEnabled = $this->pngLossy === null;
|
||||||
|
$lossyActiveEnabled = $this->lossy === true;
|
||||||
|
if ($lossyEnabled || ($lossySoftEnabled && $lossyActiveEnabled)) {
|
||||||
|
if ($this->verbose) {
|
||||||
|
clearstatcache();
|
||||||
|
$this->log("Lossy enabled: $lossyEnabled");
|
||||||
|
$this->log("Lossy soft enabled: $lossySoftEnabled");
|
||||||
|
$this->Log("Filesize before lossy optimize: " . filesize($this->cacheFileName) . " bytes.");
|
||||||
|
}
|
||||||
|
$res = array();
|
||||||
|
$cmd = $this->pngLossyCmd . " $this->cacheFileName $this->cacheFileName";
|
||||||
|
exec($cmd, $res);
|
||||||
|
$this->Log($cmd);
|
||||||
|
$this->Log($res);
|
||||||
|
}
|
||||||
|
|
||||||
// Use external program to filter PNG, if defined
|
// Use external program to filter PNG, if defined
|
||||||
if ($this->pngFilterCmd) {
|
if ($this->pngFilterCmd) {
|
||||||
if ($this->verbose) {
|
if ($this->verbose) {
|
||||||
@@ -5183,6 +5248,9 @@ verbose("upscale = $upscale");
|
|||||||
* Get details for post processing
|
* Get details for post processing
|
||||||
*/
|
*/
|
||||||
$postProcessing = getConfig('postprocessing', array(
|
$postProcessing = getConfig('postprocessing', array(
|
||||||
|
'png_lossy' => false,
|
||||||
|
'png_lossy_cmd' => '/usr/local/bin/pngquant --force --output',
|
||||||
|
|
||||||
'png_filter' => false,
|
'png_filter' => false,
|
||||||
'png_filter_cmd' => '/usr/local/bin/optipng -q',
|
'png_filter_cmd' => '/usr/local/bin/optipng -q',
|
||||||
|
|
||||||
@@ -5195,6 +5263,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.
|
* alias - Save resulting image to another alias name.
|
||||||
* Password always apply, must be defined.
|
* Password always apply, must be defined.
|
||||||
@@ -5313,7 +5390,7 @@ if ($status) {
|
|||||||
$res = $cache->getStatusOfSubdir("srgb");
|
$res = $cache->getStatusOfSubdir("srgb");
|
||||||
$text .= "Cache srgb $res\n";
|
$text .= "Cache srgb $res\n";
|
||||||
|
|
||||||
$res = $cache->getStatusOfSubdir($fasttrackCache);
|
$res = $cache->getStatusOfSubdir($fastTrackCache);
|
||||||
$text .= "Cache fasttrack $res\n";
|
$text .= "Cache fasttrack $res\n";
|
||||||
|
|
||||||
$text .= "Alias path writable = " . is_writable($aliasPath) . "\n";
|
$text .= "Alias path writable = " . is_writable($aliasPath) . "\n";
|
||||||
@@ -5330,6 +5407,11 @@ if ($status) {
|
|||||||
$no = extension_loaded('gd') ? null : 'NOT';
|
$no = extension_loaded('gd') ? null : 'NOT';
|
||||||
$text .= "Extension gd is $no loaded.<br>";
|
$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) {
|
if (!$no) {
|
||||||
$text .= print_r(gd_info(), 1);
|
$text .= print_r(gd_info(), 1);
|
||||||
}
|
}
|
||||||
@@ -5398,6 +5480,7 @@ if (is_callable($hookBeforeCImage)) {
|
|||||||
|
|
||||||
// Other
|
// Other
|
||||||
'postProcessing' => $postProcessing,
|
'postProcessing' => $postProcessing,
|
||||||
|
'lossy' => $lossy,
|
||||||
));
|
));
|
||||||
verbose(print_r($allConfig, 1));
|
verbose(print_r($allConfig, 1));
|
||||||
extract($allConfig);
|
extract($allConfig);
|
||||||
@@ -5482,6 +5565,9 @@ $img->log("Incoming arguments: " . print_r(verbose(), 1))
|
|||||||
// Output format
|
// Output format
|
||||||
'outputFormat' => $outputFormat,
|
'outputFormat' => $outputFormat,
|
||||||
'dpr' => $dpr,
|
'dpr' => $dpr,
|
||||||
|
|
||||||
|
// Postprocessing using external tools
|
||||||
|
'lossy' => $lossy,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->loadImageDetails()
|
->loadImageDetails()
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user