Compare commits
45 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ccc59fbb3a | ||
|
e85bc6cee5 | ||
|
3b7485b3b9 | ||
|
c83eac8c3c | ||
|
78ac29752e | ||
|
4b64237a4c | ||
|
85f0e3e7d3 | ||
|
da227d49dd | ||
|
26449a3236 | ||
|
20a4f848b7 | ||
|
ec3a6f3491 | ||
|
8523ef5e31 | ||
|
63112f58b1 | ||
|
c96ed10f80 | ||
|
67524bd090 | ||
|
1f9a11747b | ||
|
4ed55d59e3 | ||
|
8dde82993b | ||
|
fb261b1b05 | ||
|
1a6cef6580 | ||
|
2643d4954f | ||
|
ef1d56085a | ||
|
28cda0ea28 | ||
|
ed9949b717 | ||
|
c249a472d6 | ||
|
c8c2e5f95f | ||
|
8db8501eb0 | ||
|
2b0b3859a7 | ||
|
1e70883771 | ||
|
b2002d0087 | ||
|
9aac0cde8e | ||
|
3dec1d0a6d | ||
|
577e5fa5d4 | ||
|
38a6c86317 | ||
|
dcb390a17b | ||
|
9e461787c7 | ||
|
a96cd7a4cc | ||
|
98d971204f | ||
|
9707065b9e | ||
|
5cd953b9b3 | ||
|
b4f51f3438 | ||
|
dedd01bc71 | ||
|
67d0cf27ee | ||
|
161fdfe769 | ||
|
6cff9ac105 |
4
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
# Cache files #
|
# Cache files #
|
||||||
######################
|
######################
|
||||||
cache/_*
|
cache/*
|
||||||
|
|
||||||
|
578
CImage.php
23
LICENSE.txt
@@ -1,2 +1,21 @@
|
|||||||
This is a software solution to a general known problem.
|
The MIT License (MIT)
|
||||||
Free software. Use at own risk.
|
|
||||||
|
Copyright (c) 2012 - 2014 Mikael Roos, me@mikaelroos.se
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
24
README.md
@@ -131,6 +131,30 @@ Revision history
|
|||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
v0.5.3 (2014-11-21)
|
||||||
|
|
||||||
|
* Support filenames of uppercase JPEG, JPG, PNG and GIF, as proposed in #37.
|
||||||
|
* Changing `CImage::output()` as proposed in #37.
|
||||||
|
* Adding security check that image filename is always below the path `image_path` as specified in `img_config.php` #37.
|
||||||
|
* Adding configuration item in `img_config.php` for setting valid characters in image filename.
|
||||||
|
* Moving `webroot/test*` into directory `webroot/test`.
|
||||||
|
* `webroot/check_system.php` now outputs if extension for exif is loaded.
|
||||||
|
* Broke API when `initDimensions()` split into two methods, new `initDimensions()` and `loadImageDetails()`.
|
||||||
|
* Added `autoRotate,`aro` to auto rotate image based on EXIF information.
|
||||||
|
* Added `bgColor,`bgc` to use as backgroundcolor when needing a filler color, for example rotate 45.
|
||||||
|
* Added `rotateBefore,`rb` to rotate image a certain angle before processing.
|
||||||
|
* Added `rotateAfter,`ra` to rotate image a certain angle after processing.
|
||||||
|
* Cleaned up code formatting, removed trailing spaces.
|
||||||
|
* Removed @ from opening images, better to display correct warning when failing #34, but put it back again.
|
||||||
|
* Setting gd.jpeg_ignore_warning to true as default #34.
|
||||||
|
* `webroot/check_system.php` now outputs version of PHP and GD.
|
||||||
|
* #32 correctly send 404 header when serving an error message.
|
||||||
|
* Trying to verify issue #29, but can not.
|
||||||
|
* Adding structure for testprograms together with, use `webroot/test_issue29.php` as sample.
|
||||||
|
* Improving code formatting.
|
||||||
|
* Moving parts of verbose output from img.php to CImage.php.
|
||||||
|
|
||||||
|
|
||||||
v0.5.2 (2014-04-01)
|
v0.5.2 (2014-04-01)
|
||||||
|
|
||||||
* Correcting issue #26 providing error message when not using postprocessing.
|
* Correcting issue #26 providing error message when not using postprocessing.
|
||||||
|
15
webroot/check_system.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
echo 'Current PHP version: ' . phpversion() . '<br><br>';
|
||||||
|
|
||||||
|
echo 'Running on: ' . $_SERVER['SERVER_SOFTWARE'] . '<br><br>';
|
||||||
|
|
||||||
|
$no = extension_loaded('gd') ? null : 'NOT';
|
||||||
|
echo "Extension gd is $no loaded.<br>";
|
||||||
|
|
||||||
|
$no = extension_loaded('exif') ? null : 'NOT';
|
||||||
|
echo "Extension exif is $no loaded.<br>";
|
||||||
|
|
||||||
|
if (!$no) {
|
||||||
|
echo "<pre>", var_dump(gd_info()), "</pre>";
|
||||||
|
}
|
185
webroot/img.php
@@ -12,9 +12,9 @@
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function errorPage($msg)
|
function errorPage($msg)
|
||||||
{
|
{
|
||||||
header("Status: 404 Not Found");
|
header("HTTP/1.0 404 Not Found");
|
||||||
die('img.php say 404: ' . $msg);
|
die('img.php say 404: ' . $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ function errorPage($msg)
|
|||||||
/**
|
/**
|
||||||
* Custom exception handler.
|
* Custom exception handler.
|
||||||
*/
|
*/
|
||||||
set_exception_handler(function($exception) {
|
set_exception_handler(function ($exception) {
|
||||||
errorPage("<p><b>img.php: Uncaught exception:</b> <p>" . $exception->getMessage() . "</p><pre>" . $exception->getTraceAsString(), "</pre>");
|
errorPage("<p><b>img.php: Uncaught exception:</b> <p>" . $exception->getMessage() . "</p><pre>" . $exception->getTraceAsString(), "</pre>");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ set_exception_handler(function($exception) {
|
|||||||
*
|
*
|
||||||
* @return mixed value from $_GET or default value.
|
* @return mixed value from $_GET or default value.
|
||||||
*/
|
*/
|
||||||
function get($key, $default = null)
|
function get($key, $default = null)
|
||||||
{
|
{
|
||||||
if (is_array($key)) {
|
if (is_array($key)) {
|
||||||
foreach ($key as $val) {
|
foreach ($key as $val) {
|
||||||
@@ -62,9 +62,9 @@ function get($key, $default = null)
|
|||||||
*
|
*
|
||||||
* @return mixed value as $defined or $undefined.
|
* @return mixed value as $defined or $undefined.
|
||||||
*/
|
*/
|
||||||
function getDefined($key, $defined, $undefined)
|
function getDefined($key, $defined, $undefined)
|
||||||
{
|
{
|
||||||
return get($key) === null ? $undefined : $defined;
|
return get($key) === null ? $undefined : $defined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ function getDefined($key, $defined, $undefined)
|
|||||||
*
|
*
|
||||||
* @return void or array.
|
* @return void or array.
|
||||||
*/
|
*/
|
||||||
function verbose($msg = null)
|
function verbose($msg = null)
|
||||||
{
|
{
|
||||||
global $verbose;
|
global $verbose;
|
||||||
static $log = array();
|
static $log = array();
|
||||||
@@ -128,9 +128,32 @@ $verbose = getDefined(array('verbose', 'v'), true, false);
|
|||||||
$srcImage = get('src')
|
$srcImage = get('src')
|
||||||
or errorPage('Must set src-attribute.');
|
or errorPage('Must set src-attribute.');
|
||||||
|
|
||||||
preg_match('#^[a-z0-9A-Z-/_\.]+$#', $srcImage)
|
|
||||||
|
// Check for valid/invalid characters
|
||||||
|
preg_match($config['valid_filename'], $srcImage)
|
||||||
or errorPage('Filename contains invalid characters.');
|
or errorPage('Filename contains invalid characters.');
|
||||||
|
|
||||||
|
|
||||||
|
// Check that the image is a file below the directory 'image_path'.
|
||||||
|
if ($config['image_path_constraint']) {
|
||||||
|
|
||||||
|
$pathToImage = realpath($config['image_path'] . $srcImage);
|
||||||
|
$imageDir = realpath($config['image_path']);
|
||||||
|
|
||||||
|
is_file($pathToImage)
|
||||||
|
or errorPage(
|
||||||
|
'Source image is not a valid file, check the filename and that a
|
||||||
|
matching file exists on the filesystem.'
|
||||||
|
);
|
||||||
|
|
||||||
|
substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0
|
||||||
|
or errorPage(
|
||||||
|
'Security constraint: Source image is not below the directory "image_path"
|
||||||
|
as specified in the config file img_config.php.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
verbose("src = $srcImage");
|
verbose("src = $srcImage");
|
||||||
|
|
||||||
|
|
||||||
@@ -148,12 +171,12 @@ if (isset($sizes[$newWidth])) {
|
|||||||
|
|
||||||
// Support width as % of original width
|
// Support width as % of original width
|
||||||
if ($newWidth[strlen($newWidth)-1] == '%') {
|
if ($newWidth[strlen($newWidth)-1] == '%') {
|
||||||
is_numeric(substr($newWidth, 0, -1))
|
is_numeric(substr($newWidth, 0, -1))
|
||||||
or errorPage('Width % not numeric.');
|
or errorPage('Width % not numeric.');
|
||||||
} else {
|
} else {
|
||||||
is_null($newWidth)
|
is_null($newWidth)
|
||||||
or ($newWidth > 10 && $newWidth <= $config['max_width'])
|
or ($newWidth > 10 && $newWidth <= $config['max_width'])
|
||||||
or errorPage('Width out of range.');
|
or errorPage('Width out of range.');
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose("new width = $newWidth");
|
verbose("new width = $newWidth");
|
||||||
@@ -172,11 +195,11 @@ if (isset($sizes[$newHeight])) {
|
|||||||
|
|
||||||
// height
|
// height
|
||||||
if ($newHeight[strlen($newHeight)-1] == '%') {
|
if ($newHeight[strlen($newHeight)-1] == '%') {
|
||||||
is_numeric(substr($newHeight, 0, -1))
|
is_numeric(substr($newHeight, 0, -1))
|
||||||
or errorPage('Height % out of range.');
|
or errorPage('Height % out of range.');
|
||||||
} else {
|
} else {
|
||||||
is_null($newHeight)
|
is_null($newHeight)
|
||||||
or ($newHeight > 10 && $newHeight <= $config['max_height'])
|
or ($newHeight > 10 && $newHeight <= $config['max_height'])
|
||||||
or errorPage('Hight out of range.');
|
or errorPage('Hight out of range.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,8 +225,8 @@ if ($negateAspectRatio) {
|
|||||||
$aspectRatio = 1 / $aspectRatio;
|
$aspectRatio = 1 / $aspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
is_null($aspectRatio)
|
is_null($aspectRatio)
|
||||||
or is_numeric($aspectRatio)
|
or is_numeric($aspectRatio)
|
||||||
or errorPage('Aspect ratio out of range');
|
or errorPage('Aspect ratio out of range');
|
||||||
|
|
||||||
verbose("aspect ratio = $aspectRatio");
|
verbose("aspect ratio = $aspectRatio");
|
||||||
@@ -269,8 +292,8 @@ verbose("use cache = $useCache");
|
|||||||
*/
|
*/
|
||||||
$quality = get(array('quality', 'q'));
|
$quality = get(array('quality', 'q'));
|
||||||
|
|
||||||
is_null($quality)
|
is_null($quality)
|
||||||
or ($quality > 0 and $quality <= 100)
|
or ($quality > 0 and $quality <= 100)
|
||||||
or errorPage('Quality out of range');
|
or errorPage('Quality out of range');
|
||||||
|
|
||||||
verbose("quality = $quality");
|
verbose("quality = $quality");
|
||||||
@@ -283,8 +306,8 @@ verbose("quality = $quality");
|
|||||||
$compress = get(array('compress', 'co'));
|
$compress = get(array('compress', 'co'));
|
||||||
|
|
||||||
|
|
||||||
is_null($compress)
|
is_null($compress)
|
||||||
or ($compress > 0 and $compress <= 9)
|
or ($compress > 0 and $compress <= 9)
|
||||||
or errorPage('Compress out of range');
|
or errorPage('Compress out of range');
|
||||||
|
|
||||||
verbose("compress = $compress");
|
verbose("compress = $compress");
|
||||||
@@ -305,8 +328,8 @@ verbose("save as = $saveAs");
|
|||||||
*/
|
*/
|
||||||
$scale = get(array('scale', 's'));
|
$scale = get(array('scale', 's'));
|
||||||
|
|
||||||
is_null($scale)
|
is_null($scale)
|
||||||
or ($scale >= 0 and $quality <= 400)
|
or ($scale >= 0 and $scale <= 400)
|
||||||
or errorPage('Scale out of range');
|
or errorPage('Scale out of range');
|
||||||
|
|
||||||
verbose("scale = $scale");
|
verbose("scale = $scale");
|
||||||
@@ -349,19 +372,81 @@ verbose("blur = $blur");
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rotate - Rotate the image with an angle, before processing
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
$rotate = get(array('rotate', 'r'));
|
||||||
|
|
||||||
|
is_null($rotate)
|
||||||
|
or ($rotate >= -360 and $rotate <= 360)
|
||||||
|
or errorPage('Rotate out of range');
|
||||||
|
|
||||||
|
verbose("rotate = $rotate");
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rotateBefore - Rotate the image with an angle, before processing
|
||||||
|
*/
|
||||||
|
$rotateBefore = get(array('rotateBefore', 'rb'));
|
||||||
|
|
||||||
|
is_null($rotateBefore)
|
||||||
|
or ($rotateBefore >= -360 and $rotateBefore <= 360)
|
||||||
|
or errorPage('RotateBefore out of range');
|
||||||
|
|
||||||
|
verbose("rotateBefore = $rotateBefore");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rotateAfter - Rotate the image with an angle, before processing
|
||||||
|
*/
|
||||||
|
$rotateAfter = get(array('rotateAfter', 'ra', 'rotate', 'r'));
|
||||||
|
|
||||||
|
is_null($rotateAfter)
|
||||||
|
or ($rotateAfter >= -360 and $rotateAfter <= 360)
|
||||||
|
or errorPage('RotateBefore out of range');
|
||||||
|
|
||||||
|
verbose("rotateAfter = $rotateAfter");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bgColor - Default background color to use
|
||||||
|
*/
|
||||||
|
$bgColor = hexdec(get(array('bgColor', 'bgc')));
|
||||||
|
|
||||||
|
is_null($bgColor)
|
||||||
|
or ($bgColor >= 0 and $bgColor <= hexdec("FFFFFF"))
|
||||||
|
or errorPage('Background color needs a hex value');
|
||||||
|
|
||||||
|
verbose("bgColor = $bgColor");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* autoRotate - Auto rotate based on EXIF information
|
||||||
|
*/
|
||||||
|
$autoRotate = getDefined(array('autoRotate', 'aro'), true, false);
|
||||||
|
|
||||||
|
verbose("autoRotate = $autoRotate");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()
|
* filter, f, f0-f9 - Processing option, post filter for various effects using imagefilter()
|
||||||
*/
|
*/
|
||||||
$filters = array();
|
$filters = array();
|
||||||
$filter = get(array('filter', 'f'));
|
$filter = get(array('filter', 'f'));
|
||||||
if ($filter) {
|
if ($filter) {
|
||||||
$filters[] = $filter;
|
$filters[] = $filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < 10; $i++) {
|
for ($i = 0; $i < 10; $i++) {
|
||||||
$filter = get(array("filter{$i}", "f{$i}"));
|
$filter = get(array("filter{$i}", "f{$i}"));
|
||||||
if ($filter) {
|
if ($filter) {
|
||||||
$filters[] = $filter;
|
$filters[] = $filter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,11 +465,9 @@ if ($verbose) {
|
|||||||
unset($query['nocache']);
|
unset($query['nocache']);
|
||||||
unset($query['nc']);
|
unset($query['nc']);
|
||||||
$url1 = '?' . http_build_query($query);
|
$url1 = '?' . http_build_query($query);
|
||||||
$log = htmlentities(print_r(verbose(), 1));
|
|
||||||
echo <<<EOD
|
echo <<<EOD
|
||||||
<a href=$url1><code>$url1</code></a><br>
|
<a href=$url1><code>$url1</code></a><br>
|
||||||
<img src='{$url1}' />
|
<img src='{$url1}' />
|
||||||
<pre>$log</pre>
|
|
||||||
EOD;
|
EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,29 +481,37 @@ require $config['cimage_class'];
|
|||||||
$img = new CImage();
|
$img = new CImage();
|
||||||
|
|
||||||
$img->setVerbose($verbose)
|
$img->setVerbose($verbose)
|
||||||
|
->log("Incoming arguments: " . print_r(verbose(), 1))
|
||||||
->setSource($srcImage, $config['image_path'])
|
->setSource($srcImage, $config['image_path'])
|
||||||
->setOptions(
|
->setOptions(
|
||||||
array(
|
array(
|
||||||
// Options for calculate dimensions
|
// Options for calculate dimensions
|
||||||
'newWidth' => $newWidth,
|
'newWidth' => $newWidth,
|
||||||
'newHeight' => $newHeight,
|
'newHeight' => $newHeight,
|
||||||
'aspectRatio' => $aspectRatio,
|
'aspectRatio' => $aspectRatio,
|
||||||
'keepRatio' => $keepRatio,
|
'keepRatio' => $keepRatio,
|
||||||
'cropToFit' => $cropToFit,
|
'cropToFit' => $cropToFit,
|
||||||
'crop' => $crop,
|
'crop' => $crop,
|
||||||
'area' => $area,
|
'area' => $area,
|
||||||
|
|
||||||
// Pre-processing, before resizing is done
|
// Pre-processing, before resizing is done
|
||||||
'scale' => $scale,
|
'scale' => $scale,
|
||||||
|
'rotateBefore' => $rotateBefore,
|
||||||
|
|
||||||
// Post-processing, after resizing is done
|
// General processing options
|
||||||
'palette' => $palette,
|
'bgColor' => $bgColor,
|
||||||
'filters' => $filters,
|
|
||||||
'sharpen' => $sharpen,
|
// Post-processing, after resizing is done
|
||||||
'emboss' => $emboss,
|
'palette' => $palette,
|
||||||
'blur' => $blur,
|
'filters' => $filters,
|
||||||
|
'sharpen' => $sharpen,
|
||||||
|
'emboss' => $emboss,
|
||||||
|
'blur' => $blur,
|
||||||
|
'rotateAfter' => $rotateAfter,
|
||||||
|
'autoRotate' => $autoRotate,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
->loadImageDetails()
|
||||||
->initDimensions()
|
->initDimensions()
|
||||||
->calculateNewWidthAndHeight()
|
->calculateNewWidthAndHeight()
|
||||||
->setSaveAsExtension($saveAs)
|
->setSaveAsExtension($saveAs)
|
||||||
|
BIN
webroot/img/issue29/400x265.jpg
Normal file
After Width: | Height: | Size: 925 B |
BIN
webroot/img/issue29/400x268.jpg
Normal file
After Width: | Height: | Size: 925 B |
BIN
webroot/img/issue29/400x300.jpg
Normal file
After Width: | Height: | Size: 995 B |
BIN
webroot/img/issue29/465x304.jpg
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
webroot/img/issue29/640x273.jpg
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
webroot/img/issue34/3.jpg
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
webroot/img/issue34/4.jpg
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
webroot/img/issue36/flower-0.jpg
Normal file
After Width: | Height: | Size: 89 KiB |
BIN
webroot/img/issue36/flower-180.jpg
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
webroot/img/issue36/flower-270.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
webroot/img/issue36/flower-90.jpg
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
webroot/img/issue36/me-0.jpg
Normal file
After Width: | Height: | Size: 76 KiB |
BIN
webroot/img/issue36/me-180.jpg
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
webroot/img/issue36/me-270.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
webroot/img/issue36/me-90.jpg
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
webroot/img/round8.PNG
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
webroot/img/wider.JPEG
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
webroot/img/wider.JPG
Normal file
After Width: | Height: | Size: 70 KiB |
@@ -17,6 +17,20 @@ return array(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that the imagefile is a file below 'image_path' using realpath().
|
||||||
|
*/
|
||||||
|
'image_path_constraint' => true,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A regexp for validating characters in the image filename.
|
||||||
|
*/
|
||||||
|
'valid_filename' => '#^[a-z0-9A-Z-/_\.]+$#',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default timezone, it defaults to UTC if not specified otherwise.
|
* Set default timezone, it defaults to UTC if not specified otherwise.
|
||||||
*
|
*
|
||||||
@@ -55,7 +69,7 @@ return array(
|
|||||||
* Predefined size constants.
|
* Predefined size constants.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
'size_constant' => function() {
|
'size_constant' => function () {
|
||||||
|
|
||||||
// Set sizes to map constant to value, easier to use with width or height
|
// Set sizes to map constant to value, easier to use with width or height
|
||||||
$sizes = array(
|
$sizes = array(
|
||||||
@@ -63,13 +77,13 @@ return array(
|
|||||||
'w2' => 630,
|
'w2' => 630,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add column width to $area, useful for use as predefined size for width (or height).
|
// Add grid column width, useful for use as predefined size for width (or height).
|
||||||
$gridColumnWidth = 30;
|
$gridColumnWidth = 30;
|
||||||
$gridGutterWidth = 10;
|
$gridGutterWidth = 10;
|
||||||
$gridColumns = 24;
|
$gridColumns = 24;
|
||||||
|
|
||||||
for ($i = 1; $i <= $gridColumns; $i++) {
|
for ($i = 1; $i <= $gridColumns; $i++) {
|
||||||
$sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;
|
$sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sizes;
|
return $sizes;
|
||||||
@@ -81,7 +95,7 @@ return array(
|
|||||||
* Predefined aspect ratios.
|
* Predefined aspect ratios.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
'aspect_ratio_constant' => function() {
|
'aspect_ratio_constant' => function () {
|
||||||
return array(
|
return array(
|
||||||
'3:1' => 3/1,
|
'3:1' => 3/1,
|
||||||
'3:2' => 3/2,
|
'3:2' => 3/2,
|
||||||
@@ -98,9 +112,11 @@ return array(
|
|||||||
/**
|
/**
|
||||||
* Set error reporting to match development or production environment
|
* Set error reporting to match development or production environment
|
||||||
*/
|
*/
|
||||||
'error_reporting' => function() {
|
'error_reporting' => function () {
|
||||||
error_reporting(-1);
|
error_reporting(-1); // Report all type of errors
|
||||||
|
ini_set('display_errors', 1); // Display all errors
|
||||||
|
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
|
||||||
set_time_limit(20);
|
set_time_limit(20);
|
||||||
|
ini_set('gd.jpeg_ignore_warning', 1); // Ignore warning of corrupt jpegs
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -5,25 +5,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Testing <code>CImage.php</code> through <code>img.php</code></h1>
|
<h1>Testing <code>CImage.php</code> through <code>img.php</code></h1>
|
||||||
<p>You can test any variation of resizing the images through <a href='img.php?src=wider.jpg&w=200&h=200'>img.php?src=wider.jpg&w=200&h=200</a> or <a href='img.php?src=higher.jpg&w=200&h=200'>img.php?src=higher.jpg&w=200&h=200</a></p>
|
|
||||||
<p>Supported arguments throught the querystring are:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
|
|
||||||
<li>h, height: h=200 sets the new height to max 200px.
|
|
||||||
<li>w, width: w=200 sets the new width to max 200px.
|
|
||||||
<li>crop-to-fit: set together with both h & w to make the image fit in the box and crop out the rest.
|
|
||||||
<li>no-ratio: do not keep aspect ratio.
|
|
||||||
<li>crop: crops an area from the original image, set width, height, start_x and start_y to define the area to crop, for example crop=100,100,10,10.
|
|
||||||
<li>q, quality: q=70 or quality=70 sets the image quality as value between 0 and 100, default is full quality/100.
|
|
||||||
<li>f, filter: apply filter to image, f=colorize,0,255,0,0 makes image greener. Supports all filters as defined in <a href='http://php.net/manual/en/function.imagefilter.php'><code>imagefilter()</code></a>
|
|
||||||
<li>f0-f9: same as f/filter, just add more filters. Applied in order f, f0-f9.
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>Supports <code>.jpg</code>, <code>.png</code> and <code>.gif</code>.</p>
|
|
||||||
<p>Sourcecode and issues on github: <a href='https://github.com/mosbth/cimage'>https://github.com/mosbth/cimage</a></p>
|
|
||||||
<p>Copyright 2012, Mikael Roos (mos@dbwebb.se)</p>
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Testcases</h2>
|
<h2>Testcases</h2>
|
||||||
|
|
||||||
@@ -66,7 +47,7 @@ $testcase = array(
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach($testcase as $key => $val) {
|
foreach($testcase as $key => $val) {
|
||||||
$url = "img.php?src=wider.jpg{$val['query']}";
|
$url = "../img.php?src=wider.jpg{$val['query']}";
|
||||||
echo "<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
|
echo "<tr><td id=w$key><a href=#w$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -80,7 +61,7 @@ foreach($testcase as $key => $val) {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach($testcase as $key => $val) {
|
foreach($testcase as $key => $val) {
|
||||||
$url = "img.php?src=higher.jpg{$val['query']}";
|
$url = "../img.php?src=higher.jpg{$val['query']}";
|
||||||
echo "<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
|
echo "<tr><td id=h$key><a href=#h$key>$key</a></br>{$val['text']}</br><code><a href='$url'>".htmlentities($url)."</a></code></td><td><img src='$url' /></td></tr>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
75
webroot/test/test_issue29.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'/>
|
||||||
|
<title>Testing img for issue 29</title>
|
||||||
|
<style>
|
||||||
|
body {background-color: #ccc;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Testing issue 29</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
error_reporting(-1); // Report all type of errors
|
||||||
|
ini_set('display_errors', 1); // Display all errors
|
||||||
|
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
|
||||||
|
|
||||||
|
echo "<p>Version of PHP is: " . phpversion();
|
||||||
|
|
||||||
|
$imgphp = "../img.php?src=";
|
||||||
|
|
||||||
|
$images = array(
|
||||||
|
'issue29/400x265.jpg',
|
||||||
|
'issue29/400x268.jpg',
|
||||||
|
'issue29/400x300.jpg',
|
||||||
|
'issue29/465x304.jpg',
|
||||||
|
'issue29/640x273.jpg',
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$testcase = array(
|
||||||
|
'&w=300&cf&q=80&nc',
|
||||||
|
'&w=75&h=75&cf&q=80&nc',
|
||||||
|
'&w=75&h=75&q=80',
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Images used in test</h2>
|
||||||
|
|
||||||
|
<p>The following images are used for this test.</p>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Testcases used for each image</h2>
|
||||||
|
|
||||||
|
<p>The following testcases are used for each image.</p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<code><?=$tc?></code><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Applying testcase for each image</h2>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<h3><?=$image?></h3>
|
||||||
|
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<h4><?=$tc?></h4>
|
||||||
|
|
||||||
|
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image . $tc?>"></p>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
77
webroot/test/test_issue36_aro.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'/>
|
||||||
|
<title>Testing img for issue 36 - autoRotate</title>
|
||||||
|
<style>
|
||||||
|
body {background-color: #ccc;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Testing issue 36 - autoRotate</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
error_reporting(-1); // Report all type of errors
|
||||||
|
ini_set('display_errors', 1); // Display all errors
|
||||||
|
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
|
||||||
|
|
||||||
|
$imgphp = "../img.php?src=";
|
||||||
|
|
||||||
|
$images = array(
|
||||||
|
'issue36/me-0.jpg',
|
||||||
|
'issue36/me-90.jpg',
|
||||||
|
'issue36/me-180.jpg',
|
||||||
|
'issue36/me-270.jpg',
|
||||||
|
'issue36/flower-0.jpg',
|
||||||
|
'issue36/flower-90.jpg',
|
||||||
|
'issue36/flower-180.jpg',
|
||||||
|
'issue36/flower-270.jpg',
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$testcase = array(
|
||||||
|
'&aro&nc',
|
||||||
|
'&aro&nc&w=200',
|
||||||
|
'&aro&nc&h=200',
|
||||||
|
'&aro&nc&w=200&h=200&cf',
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Images used in test</h2>
|
||||||
|
|
||||||
|
<p>The following images are used for this test.</p>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Testcases used for each image</h2>
|
||||||
|
|
||||||
|
<p>The following testcases are used for each image.</p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<code><?=$tc?></code><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Applying testcase for each image</h2>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<h3><?=$image?></h3>
|
||||||
|
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<h4><?=$tc?></h4>
|
||||||
|
|
||||||
|
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image . $tc?>"></p>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
76
webroot/test/test_issue36_rb-ra-180.php
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
$angle = 180;
|
||||||
|
?><!doctype html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'/>
|
||||||
|
<title>Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?></title>
|
||||||
|
<style>
|
||||||
|
body {background-color: #ccc;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Testing issue 36 - rotateBefore, rotateAfter <?=$angle?></h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
error_reporting(-1); // Report all type of errors
|
||||||
|
ini_set('display_errors', 1); // Display all errors
|
||||||
|
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
|
||||||
|
|
||||||
|
$imgphp = "../img.php?src=";
|
||||||
|
|
||||||
|
$images = array(
|
||||||
|
'kodim08.png',
|
||||||
|
'kodim04.png',
|
||||||
|
);
|
||||||
|
|
||||||
|
$testcase = array(
|
||||||
|
"&rb=$angle&nc",
|
||||||
|
"&rb=$angle&nc&w=200",
|
||||||
|
"&rb=$angle&nc&h=200",
|
||||||
|
"&rb=$angle&nc&w=200&h=200&cf",
|
||||||
|
"&ra=$angle&nc",
|
||||||
|
"&ra=$angle&nc&w=200",
|
||||||
|
"&ra=$angle&nc&h=200",
|
||||||
|
"&ra=$angle&nc&w=200&h=200&cf",
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Images used in test</h2>
|
||||||
|
|
||||||
|
<p>The following images are used for this test.</p>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Testcases used for each image</h2>
|
||||||
|
|
||||||
|
<p>The following testcases are used for each image.</p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<code><?=$tc?></code><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Applying testcase for each image</h2>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<h3><?=$image?></h3>
|
||||||
|
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<h4><?=$tc?></h4>
|
||||||
|
|
||||||
|
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image . $tc?>"></p>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
76
webroot/test/test_issue36_rb-ra-270.php
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
$angle = 270;
|
||||||
|
?><!doctype html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'/>
|
||||||
|
<title>Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?></title>
|
||||||
|
<style>
|
||||||
|
body {background-color: #ccc;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Testing issue 36 - rotateBefore, rotateAfter <?=$angle?></h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
error_reporting(-1); // Report all type of errors
|
||||||
|
ini_set('display_errors', 1); // Display all errors
|
||||||
|
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
|
||||||
|
|
||||||
|
$imgphp = "../img.php?src=";
|
||||||
|
|
||||||
|
$images = array(
|
||||||
|
'kodim08.png',
|
||||||
|
'kodim04.png',
|
||||||
|
);
|
||||||
|
|
||||||
|
$testcase = array(
|
||||||
|
"&rb=$angle&nc",
|
||||||
|
"&rb=$angle&nc&w=200",
|
||||||
|
"&rb=$angle&nc&h=200",
|
||||||
|
"&rb=$angle&nc&w=200&h=200&cf",
|
||||||
|
"&ra=$angle&nc",
|
||||||
|
"&ra=$angle&nc&w=200",
|
||||||
|
"&ra=$angle&nc&h=200",
|
||||||
|
"&ra=$angle&nc&w=200&h=200&cf",
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Images used in test</h2>
|
||||||
|
|
||||||
|
<p>The following images are used for this test.</p>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Testcases used for each image</h2>
|
||||||
|
|
||||||
|
<p>The following testcases are used for each image.</p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<code><?=$tc?></code><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Applying testcase for each image</h2>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<h3><?=$image?></h3>
|
||||||
|
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<h4><?=$tc?></h4>
|
||||||
|
|
||||||
|
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image . $tc?>"></p>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
78
webroot/test/test_issue36_rb-ra-45.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
$angle = 45;
|
||||||
|
?><!doctype html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'/>
|
||||||
|
<title>Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?></title>
|
||||||
|
<style>
|
||||||
|
body {background-color: #ccc;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Testing issue 36 - rotateBefore, rotateAfter <?=$angle?></h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
error_reporting(-1); // Report all type of errors
|
||||||
|
ini_set('display_errors', 1); // Display all errors
|
||||||
|
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
|
||||||
|
|
||||||
|
$imgphp = "../img.php?src=";
|
||||||
|
|
||||||
|
$images = array(
|
||||||
|
'kodim08.png',
|
||||||
|
'kodim04.png',
|
||||||
|
);
|
||||||
|
|
||||||
|
$testcase = array(
|
||||||
|
"&rb=$angle&bgc=ffffff&nc",
|
||||||
|
"&rb=$angle&bgc=ffffff&nc&w=200",
|
||||||
|
"&rb=$angle&bgc=ffffff&nc&h=200",
|
||||||
|
"&rb=$angle&bgc=ffffff&nc&w=200&h=200&cf",
|
||||||
|
"&rb=$angle&bgc=ffffff&nc&w=200&h=200&cf&crop=200,200,center,center",
|
||||||
|
"&ra=$angle&bgc=ffffff&nc",
|
||||||
|
"&ra=$angle&bgc=ffffff&nc&w=200",
|
||||||
|
"&ra=$angle&bgc=ffffff&nc&h=200",
|
||||||
|
"&ra=$angle&bgc=ffffff&nc&w=200&h=200&cf",
|
||||||
|
"&ra=$angle&bgc=ffffff&nc&w=200&h=200&cf&crop=200,200,center,center",
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Images used in test</h2>
|
||||||
|
|
||||||
|
<p>The following images are used for this test.</p>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Testcases used for each image</h2>
|
||||||
|
|
||||||
|
<p>The following testcases are used for each image.</p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<code><?=$tc?></code><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Applying testcase for each image</h2>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<h3><?=$image?></h3>
|
||||||
|
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<h4><?=$tc?></h4>
|
||||||
|
|
||||||
|
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image . $tc?>"></p>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
76
webroot/test/test_issue36_rb-ra-90.php
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
$angle = 90;
|
||||||
|
?><!doctype html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'/>
|
||||||
|
<title>Testing img for issue 36 - rotateBefore, rotateAfter <?=$angle?></title>
|
||||||
|
<style>
|
||||||
|
body {background-color: #ccc;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Testing issue 36 - rotateBefore, rotateAfter <?=$angle?></h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
error_reporting(-1); // Report all type of errors
|
||||||
|
ini_set('display_errors', 1); // Display all errors
|
||||||
|
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
|
||||||
|
|
||||||
|
$imgphp = "../img.php?src=";
|
||||||
|
|
||||||
|
$images = array(
|
||||||
|
'kodim08.png',
|
||||||
|
'kodim04.png',
|
||||||
|
);
|
||||||
|
|
||||||
|
$testcase = array(
|
||||||
|
"&rb=$angle&nc",
|
||||||
|
"&rb=$angle&nc&w=200",
|
||||||
|
"&rb=$angle&nc&h=200",
|
||||||
|
"&rb=$angle&nc&w=200&h=200&cf",
|
||||||
|
"&ra=$angle&nc",
|
||||||
|
"&ra=$angle&nc&w=200",
|
||||||
|
"&ra=$angle&nc&h=200",
|
||||||
|
"&ra=$angle&nc&w=200&h=200&cf",
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Images used in test</h2>
|
||||||
|
|
||||||
|
<p>The following images are used for this test.</p>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Testcases used for each image</h2>
|
||||||
|
|
||||||
|
<p>The following testcases are used for each image.</p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<code><?=$tc?></code><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Applying testcase for each image</h2>
|
||||||
|
|
||||||
|
<?php foreach($images as $image) : ?>
|
||||||
|
<h3><?=$image?></h3>
|
||||||
|
|
||||||
|
<p><code><a href="img/<?=$image?>"><?=$image?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image?>"></p>
|
||||||
|
|
||||||
|
<?php foreach($testcase as $tc) : ?>
|
||||||
|
<h4><?=$tc?></h4>
|
||||||
|
|
||||||
|
<p><code><a href="<?=$imgphp . $image . $tc?>"><?=$image . $tc?></a></code><br>
|
||||||
|
<img src="<?=$imgphp . $image . $tc?>"></p>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|