mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-03 14:47:47 +02:00
Adding option &status to get an overview of the installed ond configured utilities, #116.
This commit is contained in:
@@ -8,6 +8,9 @@ Revision history
|
|||||||
v0.7.6* (2015-10-20)
|
v0.7.6* (2015-10-20)
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
|
* Adding option &status to get an overview of the installed ond configured utilities.
|
||||||
|
* Bug, all files saved as png-files, when not saving as specific file.
|
||||||
|
* Removed saving filename extension for alias images.
|
||||||
* Added option to decide if resample or resize when copying images internally. `&no-resample` makes resize, instead of resample as is default.
|
* Added option to decide if resample or resize when copying images internally. `&no-resample` makes resize, instead of resample as is default.
|
||||||
* Verbose now correctly states if transparent color is detected.
|
* Verbose now correctly states if transparent color is detected.
|
||||||
* Compare-tool now supports 6 images.
|
* Compare-tool now supports 6 images.
|
||||||
|
118
webroot/img.php
118
webroot/img.php
@@ -157,6 +157,13 @@ verbose("img.php version = $version");
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* status - do a verbose dump of the configuration
|
||||||
|
*/
|
||||||
|
$status = getDefined('status', true, false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set mode as strict, production or development.
|
* Set mode as strict, production or development.
|
||||||
* Default is production environment.
|
* Default is production environment.
|
||||||
@@ -178,6 +185,7 @@ if ($mode == 'strict') {
|
|||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
$status = false;
|
||||||
$verboseFile = false;
|
$verboseFile = false;
|
||||||
|
|
||||||
} elseif ($mode == 'production') {
|
} elseif ($mode == 'production') {
|
||||||
@@ -186,6 +194,7 @@ if ($mode == 'strict') {
|
|||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
$status = false;
|
||||||
$verboseFile = false;
|
$verboseFile = false;
|
||||||
|
|
||||||
} elseif ($mode == 'development') {
|
} elseif ($mode == 'development') {
|
||||||
@@ -910,6 +919,75 @@ $cachePath = getConfig('cache_path', __DIR__ . '/../cache/');
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare a dummy image and use it as source image.
|
||||||
|
*/
|
||||||
|
$dummyDir = getConfig('dummy_dir', $cachePath. "/" . $dummyFilename);
|
||||||
|
|
||||||
|
if ($dummyImage === true) {
|
||||||
|
is_writable($dummyDir)
|
||||||
|
or verbose("dummy dir not writable = $dummyDir");
|
||||||
|
|
||||||
|
$img->setSaveFolder($dummyDir)
|
||||||
|
->setSource($dummyFilename, $dummyDir)
|
||||||
|
->setOptions(
|
||||||
|
array(
|
||||||
|
'newWidth' => $newWidth,
|
||||||
|
'newHeight' => $newHeight,
|
||||||
|
'bgColor' => $bgColor,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->setJpegQuality($quality)
|
||||||
|
->setPngCompression($compress)
|
||||||
|
->createDummyImage()
|
||||||
|
->generateFilename(null, false)
|
||||||
|
->save(null, null, false);
|
||||||
|
|
||||||
|
$srcImage = $img->getTarget();
|
||||||
|
$imagePath = null;
|
||||||
|
|
||||||
|
verbose("src (updated) = $srcImage");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display status
|
||||||
|
*/
|
||||||
|
if ($status) {
|
||||||
|
$text = "img.php version = $version\n";
|
||||||
|
$text .= "PHP version = " . PHP_VERSION . "\n";
|
||||||
|
$text .= "Running on: " . $_SERVER['SERVER_SOFTWARE'] . "\n";
|
||||||
|
$text .= "Allow remote images = $allowRemote\n";
|
||||||
|
$text .= "Cache writable = " . is_writable($cachePath) . "\n";
|
||||||
|
$text .= "Cache dummy writable = " . is_writable($dummyDir) . "\n";
|
||||||
|
$text .= "Alias path writable = " . is_writable($aliasPath) . "\n";
|
||||||
|
|
||||||
|
$no = extension_loaded('exif') ? null : 'NOT';
|
||||||
|
$text .= "Extension exif is $no loaded.<br>";
|
||||||
|
|
||||||
|
$no = extension_loaded('curl') ? null : 'NOT';
|
||||||
|
$text .= "Extension curl is $no loaded.<br>";
|
||||||
|
|
||||||
|
$no = extension_loaded('gd') ? null : 'NOT';
|
||||||
|
$text .= "Extension gd is $no loaded.<br>";
|
||||||
|
|
||||||
|
if (!$no) {
|
||||||
|
$text .= print_r(gd_info(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo <<<EOD
|
||||||
|
<!doctype html>
|
||||||
|
<html lang=en>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
<title>CImage status</title>
|
||||||
|
<pre>$text</pre>
|
||||||
|
EOD;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display image if verbose mode
|
* Display image if verbose mode
|
||||||
*/
|
*/
|
||||||
@@ -937,7 +1015,7 @@ if ($verbose) {
|
|||||||
window.getDetails = function (url, id) {
|
window.getDetails = function (url, id) {
|
||||||
$.getJSON(url, function(data) {
|
$.getJSON(url, function(data) {
|
||||||
element = document.getElementById(id);
|
element = document.getElementById(id);
|
||||||
element.innerHTML = "filename: " + data.filename + "\\nmime type: " + data.mimeType + "\\ncolors: " + data.colors + "\\nsize: " + data.size + "\\nwidth: " + data.width + "\\nheigh: " + data.height + "\\naspect-ratio: " + data.aspectRatio + "\\npng-type: " + data.pngType;
|
element.innerHTML = "filename: " + data.filename + "\\nmime type: " + data.mimeType + "\\ncolors: " + data.colors + "\\nsize: " + data.size + "\\nwidth: " + data.width + "\\nheigh: " + data.height + "\\naspect-ratio: " + data.aspectRatio + ( data.pngType ? "\\npng-type: " + data.pngType : '');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -956,44 +1034,6 @@ if ($verboseFile) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set basic options for image processing.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare a dummy image and use it as source image.
|
|
||||||
*/
|
|
||||||
if ($dummyImage === true) {
|
|
||||||
|
|
||||||
$dummyDir = getConfig('dummy_dir', $cachePath. "/" . $dummyFilename);
|
|
||||||
|
|
||||||
is_writable($dummyDir)
|
|
||||||
or verbose("dummy dir not writable = $dummyDir");
|
|
||||||
|
|
||||||
$img->setSaveFolder($dummyDir)
|
|
||||||
->setSource($dummyFilename, $dummyDir)
|
|
||||||
->setOptions(
|
|
||||||
array(
|
|
||||||
'newWidth' => $newWidth,
|
|
||||||
'newHeight' => $newHeight,
|
|
||||||
'bgColor' => $bgColor,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
->setJpegQuality($quality)
|
|
||||||
->setPngCompression($compress)
|
|
||||||
->createDummyImage()
|
|
||||||
->generateFilename(null, false)
|
|
||||||
->save(null, null, false);
|
|
||||||
|
|
||||||
$srcImage = $img->getTarget();
|
|
||||||
$imagePath = null;
|
|
||||||
|
|
||||||
verbose("src (updated) = $srcImage");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load, process and output the image
|
* Load, process and output the image
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user