mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-03 14:47:47 +02:00
clear whitespace
This commit is contained in:
@@ -175,7 +175,7 @@ class CAsciiArt
|
|||||||
*/
|
*/
|
||||||
public function getLuminance($red, $green, $blue)
|
public function getLuminance($red, $green, $blue)
|
||||||
{
|
{
|
||||||
switch($this->luminanceStrategy) {
|
switch ($this->luminanceStrategy) {
|
||||||
case 1:
|
case 1:
|
||||||
$luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;
|
$luminance = ($red * 0.2126 + $green * 0.7152 + $blue * 0.0722) / 255;
|
||||||
break;
|
break;
|
||||||
|
@@ -75,7 +75,7 @@ class CCache
|
|||||||
{
|
{
|
||||||
$path = realpath($this->path . "/" . $subdir);
|
$path = realpath($this->path . "/" . $subdir);
|
||||||
|
|
||||||
$exists = is_dir($path);
|
$exists = is_dir($path);
|
||||||
$res = $exists ? "exists" : "does not exist";
|
$res = $exists ? "exists" : "does not exist";
|
||||||
|
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
|
24
CImage.php
24
CImage.php
@@ -208,8 +208,8 @@ class CImage
|
|||||||
/**
|
/**
|
||||||
* Path to command to optimize jpeg images, for example jpegtran or null.
|
* Path to command to optimize jpeg images, for example jpegtran or null.
|
||||||
*/
|
*/
|
||||||
private $jpegOptimize;
|
private $jpegOptimize;
|
||||||
private $jpegOptimizeCmd;
|
private $jpegOptimizeCmd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ class CImage
|
|||||||
*/
|
*/
|
||||||
const RESIZE = 1;
|
const RESIZE = 1;
|
||||||
const RESAMPLE = 2;
|
const RESAMPLE = 2;
|
||||||
private $copyStrategy = NULL;
|
private $copyStrategy = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -631,7 +631,7 @@ class CImage
|
|||||||
|
|
||||||
if ($extension == 'jpeg') {
|
if ($extension == 'jpeg') {
|
||||||
$extension = 'jpg';
|
$extension = 'jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $extension;
|
return $extension;
|
||||||
}
|
}
|
||||||
@@ -1619,11 +1619,11 @@ class CImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setCopyResizeStrategy($strategy)
|
public function setCopyResizeStrategy($strategy)
|
||||||
{
|
{
|
||||||
$this->copyStrategy = $strategy;
|
$this->copyStrategy = $strategy;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1634,7 +1634,7 @@ class CImage
|
|||||||
*/
|
*/
|
||||||
public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
|
public function imageCopyResampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
|
||||||
{
|
{
|
||||||
if($this->copyStrategy == self::RESIZE) {
|
if ($this->copyStrategy == self::RESIZE) {
|
||||||
$this->log("Copy by resize");
|
$this->log("Copy by resize");
|
||||||
imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
|
imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
|
||||||
} else {
|
} else {
|
||||||
@@ -2312,7 +2312,7 @@ class CImage
|
|||||||
|
|
||||||
$type = $this->getTargetImageExtension();
|
$type = $this->getTargetImageExtension();
|
||||||
$this->Log("Saving image as " . $type);
|
$this->Log("Saving image as " . $type);
|
||||||
switch($type) {
|
switch ($type) {
|
||||||
|
|
||||||
case 'jpeg':
|
case 'jpeg':
|
||||||
case 'jpg':
|
case 'jpg':
|
||||||
@@ -2549,7 +2549,7 @@ class CImage
|
|||||||
header('Last-Modified: ' . $gmdate . " GMT");
|
header('Last-Modified: ' . $gmdate . " GMT");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->HTTPHeader as $key => $val) {
|
foreach ($this->HTTPHeader as $key => $val) {
|
||||||
header("$key: $val");
|
header("$key: $val");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ class CImageRemoteDownloadTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAllowRemoteDownloadDefaultPatternValid($source)
|
public function testAllowRemoteDownloadDefaultPatternValid($source)
|
||||||
{
|
{
|
||||||
$img = new CImage();
|
$img = new CImage();
|
||||||
$img->setRemoteDownload(true);
|
$img->setRemoteDownload(true, "");
|
||||||
|
|
||||||
$res = $img->isRemoteSource($source);
|
$res = $img->isRemoteSource($source);
|
||||||
$this->assertTrue($res, "Should be a valid remote source: '$source'.");
|
$this->assertTrue($res, "Should be a valid remote source: '$source'.");
|
||||||
@@ -79,7 +79,7 @@ class CImageRemoteDownloadTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAllowRemoteDownloadDefaultPatternInvalid($source)
|
public function testAllowRemoteDownloadDefaultPatternInvalid($source)
|
||||||
{
|
{
|
||||||
$img = new CImage();
|
$img = new CImage();
|
||||||
$img->setRemoteDownload(true);
|
$img->setRemoteDownload(true, "");
|
||||||
|
|
||||||
$res = $img->isRemoteSource($source);
|
$res = $img->isRemoteSource($source);
|
||||||
$this->assertFalse($res, "Should not be a valid remote source: '$source'.");
|
$this->assertFalse($res, "Should not be a valid remote source: '$source'.");
|
||||||
|
@@ -38,7 +38,7 @@ class CImageSRGBTest extends \PHPUnit_Framework_TestCase
|
|||||||
$img = new CImage();
|
$img = new CImage();
|
||||||
|
|
||||||
$filename = $img->convert2sRGBColorSpace(
|
$filename = $img->convert2sRGBColorSpace(
|
||||||
'car.png',
|
'car.png',
|
||||||
IMAGE_PATH,
|
IMAGE_PATH,
|
||||||
$this->cache,
|
$this->cache,
|
||||||
$this->srgbColorProfile
|
$this->srgbColorProfile
|
||||||
@@ -63,8 +63,8 @@ class CImageSRGBTest extends \PHPUnit_Framework_TestCase
|
|||||||
$img = new CImage();
|
$img = new CImage();
|
||||||
|
|
||||||
$filename = $img->convert2sRGBColorSpace(
|
$filename = $img->convert2sRGBColorSpace(
|
||||||
'car.jpg',
|
'car.jpg',
|
||||||
IMAGE_PATH,
|
IMAGE_PATH,
|
||||||
$this->cache,
|
$this->cache,
|
||||||
$this->srgbColorProfile
|
$this->srgbColorProfile
|
||||||
);
|
);
|
||||||
|
@@ -30,10 +30,10 @@ function errorPage($msg, $type = 500)
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 403:
|
case 403:
|
||||||
$header = "403 Forbidden";
|
$header = "403 Forbidden";
|
||||||
break;
|
break;
|
||||||
case 404:
|
case 404:
|
||||||
$header = "404 Not Found";
|
$header = "404 Not Found";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$header = "500 Internal Server Error";
|
$header = "500 Internal Server Error";
|
||||||
}
|
}
|
||||||
@@ -63,8 +63,9 @@ set_exception_handler(function ($exception) {
|
|||||||
. $exception->getMessage()
|
. $exception->getMessage()
|
||||||
. "</p><pre>"
|
. "</p><pre>"
|
||||||
. $exception->getTraceAsString()
|
. $exception->getTraceAsString()
|
||||||
. "</pre>"
|
. "</pre>",
|
||||||
, 500);
|
500
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -263,7 +264,7 @@ $pwd = get(array('password', 'pwd'), null);
|
|||||||
// Check if passwords match, if configured to use passwords
|
// Check if passwords match, if configured to use passwords
|
||||||
$passwordMatch = null;
|
$passwordMatch = null;
|
||||||
if ($pwd) {
|
if ($pwd) {
|
||||||
switch($pwdType) {
|
switch ($pwdType) {
|
||||||
case 'md5':
|
case 'md5':
|
||||||
$passwordMatch = ($pwdConfig === md5($pwd));
|
$passwordMatch = ($pwdConfig === md5($pwd));
|
||||||
break;
|
break;
|
||||||
@@ -439,14 +440,16 @@ if ($dummyEnabled && $srcImage === $dummyFilename) {
|
|||||||
is_file($pathToImage)
|
is_file($pathToImage)
|
||||||
or errorPage(
|
or errorPage(
|
||||||
'Source image is not a valid file, check the filename and that a
|
'Source image is not a valid file, check the filename and that a
|
||||||
matching file exists on the filesystem.'
|
matching file exists on the filesystem.',
|
||||||
, 404);
|
404
|
||||||
|
);
|
||||||
|
|
||||||
substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0
|
substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0
|
||||||
or errorPage(
|
or errorPage(
|
||||||
'Security constraint: Source image is not below the directory "image_path"
|
'Security constraint: Source image is not below the directory "image_path"
|
||||||
as specified in the config file img_config.php.'
|
as specified in the config file img_config.php.',
|
||||||
, 404);
|
404
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose("src = $srcImage");
|
verbose("src = $srcImage");
|
||||||
|
Reference in New Issue
Block a user