103
webroot/img.php
@@ -306,7 +306,7 @@ verbose("save as = $saveAs");
|
||||
$scale = get(array('scale', 's'));
|
||||
|
||||
is_null($scale)
|
||||
or ($scale >= 0 and $quality <= 400)
|
||||
or ($scale >= 0 and $scale <= 400)
|
||||
or errorPage('Scale out of range');
|
||||
|
||||
verbose("scale = $scale");
|
||||
@@ -349,6 +349,68 @@ 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()
|
||||
*/
|
||||
@@ -400,26 +462,33 @@ $img->setVerbose($verbose)
|
||||
->setSource($srcImage, $config['image_path'])
|
||||
->setOptions(
|
||||
array(
|
||||
// Options for calculate dimensions
|
||||
'newWidth' => $newWidth,
|
||||
'newHeight' => $newHeight,
|
||||
'aspectRatio' => $aspectRatio,
|
||||
'keepRatio' => $keepRatio,
|
||||
'cropToFit' => $cropToFit,
|
||||
'crop' => $crop,
|
||||
'area' => $area,
|
||||
// Options for calculate dimensions
|
||||
'newWidth' => $newWidth,
|
||||
'newHeight' => $newHeight,
|
||||
'aspectRatio' => $aspectRatio,
|
||||
'keepRatio' => $keepRatio,
|
||||
'cropToFit' => $cropToFit,
|
||||
'crop' => $crop,
|
||||
'area' => $area,
|
||||
|
||||
// Pre-processing, before resizing is done
|
||||
'scale' => $scale,
|
||||
// Pre-processing, before resizing is done
|
||||
'scale' => $scale,
|
||||
'rotateBefore' => $rotateBefore,
|
||||
|
||||
// Post-processing, after resizing is done
|
||||
'palette' => $palette,
|
||||
'filters' => $filters,
|
||||
'sharpen' => $sharpen,
|
||||
'emboss' => $emboss,
|
||||
'blur' => $blur,
|
||||
// General processing options
|
||||
'bgColor' => $bgColor,
|
||||
|
||||
// Post-processing, after resizing is done
|
||||
'palette' => $palette,
|
||||
'filters' => $filters,
|
||||
'sharpen' => $sharpen,
|
||||
'emboss' => $emboss,
|
||||
'blur' => $blur,
|
||||
'rotateAfter' => $rotateAfter,
|
||||
'autoRotate' => $autoRotate,
|
||||
)
|
||||
)
|
||||
->loadImageDetails()
|
||||
->initDimensions()
|
||||
->calculateNewWidthAndHeight()
|
||||
->setSaveAsExtension($saveAs)
|
||||
|
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 |
77
webroot/test_issue36.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset='utf-8'/>
|
||||
<title>Testing img for issue 36</title>
|
||||
<style>
|
||||
body {background-color: #ccc;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Testing issue 36</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; ?>
|
||||
|