mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-20 14:51:23 +02:00
adding CCache to improve cache handling of dummy and srgb
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
$version = "v0.7.8 (2015-12-06)";
|
||||
$version = "v0.7.8* (2015-12-06)";
|
||||
|
||||
|
||||
|
||||
@@ -943,11 +943,13 @@ verbose("alias = $alias");
|
||||
* Get the cachepath from config.
|
||||
*/
|
||||
$cachePath = getConfig('cache_path', __DIR__ . '/../cache/');
|
||||
$cache = new CCache();
|
||||
$cache->setDir($cachePath);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the cachepath from config.
|
||||
* Add cache control HTTP header.
|
||||
*/
|
||||
$cacheControl = getConfig('cache_control', null);
|
||||
|
||||
@@ -961,11 +963,8 @@ if ($cacheControl) {
|
||||
/**
|
||||
* 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");
|
||||
$dummyDir = $cache->getPathToSubdir("dummy");
|
||||
|
||||
$img->setSaveFolder($dummyDir)
|
||||
->setSource($dummyFilename, $dummyDir)
|
||||
@@ -993,24 +992,16 @@ if ($dummyImage === true) {
|
||||
/**
|
||||
* Prepare a sRGB version of the image and use it as source image.
|
||||
*/
|
||||
$srgbDirName = "/srgb";
|
||||
$srgbDir = realpath(getConfig('srgb_dir', $cachePath . $srgbDirName));
|
||||
$srgbDefault = getConfig('srgb_default', false);
|
||||
$srgbColorProfile = getConfig('srgb_colorprofile', __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc');
|
||||
$srgb = getDefined('srgb', true, null);
|
||||
|
||||
if ($srgb || $srgbDefault) {
|
||||
|
||||
if (!is_writable($srgbDir)) {
|
||||
if (is_writable($cachePath)) {
|
||||
mkdir($srgbDir);
|
||||
}
|
||||
}
|
||||
|
||||
$filename = $img->convert2sRGBColorSpace(
|
||||
$srcImage,
|
||||
$imagePath,
|
||||
$srgbDir,
|
||||
$cache->getPathToSubdir("srgb"),
|
||||
$srgbColorProfile,
|
||||
$useCache
|
||||
);
|
||||
@@ -1034,9 +1025,16 @@ if ($status) {
|
||||
$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 .= "Cache srgb writable = " . is_writable($srgbDir) . "\n";
|
||||
|
||||
$res = $cache->getStatusOfSubdir("");
|
||||
$text .= "Cache $res\n";
|
||||
|
||||
$res = $cache->getStatusOfSubdir("dummy");
|
||||
$text .= "Cache dummy $res\n";
|
||||
|
||||
$res = $cache->getStatusOfSubdir("srgb");
|
||||
$text .= "Cache srgb $res\n";
|
||||
|
||||
$text .= "Alias path writable = " . is_writable($aliasPath) . "\n";
|
||||
|
||||
$no = extension_loaded('exif') ? null : 'NOT';
|
||||
|
@@ -14,7 +14,7 @@ return array(
|
||||
* mode: 'production'
|
||||
*/
|
||||
//'mode' => 'production', // 'development', 'strict'
|
||||
//'mode' => 'development', // 'development', 'strict'
|
||||
'mode' => 'development', // 'development', 'strict'
|
||||
|
||||
|
||||
|
||||
@@ -124,17 +124,15 @@ return array(
|
||||
|
||||
/**
|
||||
* Convert the image to srgb before processing. Saves the converted
|
||||
* image in the sub cache dir. This option is default false but can
|
||||
* image in a cache subdir 'srgb'. This option is default false but can
|
||||
* be changed to default true to do this conversion for all images.
|
||||
* This option requires PHP extension imagick and will silently fail
|
||||
* if that is not installed.
|
||||
*
|
||||
* Default value:
|
||||
* srgb_dir: $cachePath/srgb
|
||||
* srgb_default: false
|
||||
* srgb_colorprofile: __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc'
|
||||
*/
|
||||
//'srgb_dir' => __DIR__ . '/../cache/srgb/',
|
||||
//'srgb_default' => false,
|
||||
//'srgb_colorprofile' => __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc',
|
||||
|
||||
@@ -170,23 +168,19 @@ return array(
|
||||
|
||||
/**
|
||||
* The name representing a dummy image which is automatically created
|
||||
* and stored at the defined path. The dummy image can then be used
|
||||
* inplace of an original image as a placeholder.
|
||||
* The dummy_dir must be writable and it defaults to a subdir of the
|
||||
* cache directory.
|
||||
* Write protect the dummy_dir to prevent creation of new dummy images,
|
||||
* but continue to use the existing ones.
|
||||
* and stored as a image in the dir CACHE_PATH/dummy. The dummy image
|
||||
* can then be used as a placeholder image.
|
||||
* The dir CACHE_PATH/dummy is automatically created when needed.
|
||||
* Write protect the CACHE_PATH/dummy to prevent creation of new
|
||||
* dummy images, but continue to use the existing ones.
|
||||
*
|
||||
* Default value:
|
||||
* dummy_enabled: true as default, disable dummy feature by setting
|
||||
* to false.
|
||||
* dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.
|
||||
* dummy_dir: Defaults to subdirectory of 'cache_path',
|
||||
* named the same as 'dummy_filename'
|
||||
*/
|
||||
//'dummy_enabled' => true,
|
||||
//'dummy_filename' => 'dummy',
|
||||
//'dummy_dir' => 'some writable directory',
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user