mirror of
https://github.com/Intervention/image.git
synced 2025-08-30 01:00:06 +02:00
Renamed a few exception classes, and added unit tests.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<phpunit backupGlobals="false"
|
<phpunit backupGlobals="false"
|
||||||
backupStaticAttributes="false"
|
backupStaticAttributes="false"
|
||||||
bootstrap="vendor/autoload.php"
|
bootstrap="vendor/autoload.php"
|
||||||
colors="true"
|
colors="false"
|
||||||
convertErrorsToExceptions="true"
|
convertErrorsToExceptions="true"
|
||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
|
1
public/text.txt
Normal file
1
public/text.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Some Text.
|
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Intervention\Image\Exception;
|
||||||
|
|
||||||
|
class BrightnessOutOfBoundsException extends \OutOfBoundsException
|
||||||
|
{
|
||||||
|
# nothing to override
|
||||||
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Intervention\Image\Exception;
|
namespace Intervention\Image\Exception;
|
||||||
|
|
||||||
class ImageDimensionException extends \RuntimeException
|
class ContrastOutOfBoundsException extends \OutOfBoundsException
|
||||||
{
|
{
|
||||||
# nothing to override
|
# nothing to override
|
||||||
}
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Intervention\Image\Exception;
|
namespace Intervention\Image\Exception;
|
||||||
|
|
||||||
class ImageOpacityException extends \RuntimeException
|
class DimensionOutOfBoundsException extends \OutOfBoundsException
|
||||||
{
|
{
|
||||||
# nothing to override
|
# nothing to override
|
||||||
}
|
}
|
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Intervention\Image\Exception;
|
||||||
|
|
||||||
|
class ExifFunctionsNotAvailableException extends \RuntimeException
|
||||||
|
{
|
||||||
|
# nothing to override
|
||||||
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Intervention\Image\Exception;
|
namespace Intervention\Image\Exception;
|
||||||
|
|
||||||
class ImageBrightnessException extends \RuntimeException
|
class InvalidImageDataStringException extends \RuntimeException
|
||||||
{
|
{
|
||||||
# nothing to override
|
# nothing to override
|
||||||
}
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Intervention\Image\Exception;
|
namespace Intervention\Image\Exception;
|
||||||
|
|
||||||
class ImageConstractException extends \RuntimeException
|
class OpacityOutOfBoundsException extends \OutOfBoundsException
|
||||||
{
|
{
|
||||||
# nothing to override
|
# nothing to override
|
||||||
}
|
}
|
@@ -161,12 +161,16 @@ class Image
|
|||||||
* @param Closure $callback
|
* @param Closure $callback
|
||||||
* @param integer $lifetime
|
* @param integer $lifetime
|
||||||
* @param boolean $returnObj
|
* @param boolean $returnObj
|
||||||
|
*
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
public static function cache(Closure $callback = null, $lifetime = null, $returnObj = false)
|
public static function cache(Closure $callback = null, $lifetime = null, $returnObj = false)
|
||||||
{
|
{
|
||||||
if ( ! class_exists('\Intervention\Image\ImageCache')) {
|
if ( ! class_exists('\Intervention\Image\ImageCache')) {
|
||||||
throw new Exception\ImageCacheNotFoundException('Please install package intervention/imagecache before running this function.');
|
throw new Exception\ImageCacheNotFoundException(
|
||||||
|
'Please install package intervention/imagecache before
|
||||||
|
running this function.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create image and run callback
|
// Create image and run callback
|
||||||
@@ -185,7 +189,9 @@ class Image
|
|||||||
private function initFromPath($path)
|
private function initFromPath($path)
|
||||||
{
|
{
|
||||||
if ( ! file_exists($path)) {
|
if ( ! file_exists($path)) {
|
||||||
throw new Exception\ImageNotFoundException("Image file ({$path}) not found");
|
throw new Exception\ImageNotFoundException(
|
||||||
|
"Image file ({$path}) not found"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set file info
|
// set file info
|
||||||
@@ -383,7 +389,7 @@ class Image
|
|||||||
// throw an exception.
|
// throw an exception.
|
||||||
if (is_null($width) && is_null($height)) {
|
if (is_null($width) && is_null($height)) {
|
||||||
|
|
||||||
throw new Exception\ImageDimensionException('width or height needs to be defined');
|
throw new Exception\DimensionOutOfBoundsException('width or height needs to be defined');
|
||||||
|
|
||||||
} elseif (is_null($width)) { // If only the width hasn't been set, keep the current width.
|
} elseif (is_null($width)) { // If only the width hasn't been set, keep the current width.
|
||||||
|
|
||||||
@@ -599,7 +605,9 @@ class Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($width) || is_null($height)) {
|
if (is_null($width) || is_null($height)) {
|
||||||
throw new Exception\ImageDimensionException('width and height of cutout needs to be defined');
|
throw new Exception\DimensionOutOfBoundsException(
|
||||||
|
'width and height of cutout needs to be defined'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->modify(0, 0, $pos_x , $pos_y, $width, $height, $width, $height);
|
return $this->modify(0, 0, $pos_x , $pos_y, $width, $height, $width, $height);
|
||||||
@@ -630,7 +638,9 @@ class Image
|
|||||||
$height = is_null($height) ? $width : $height;
|
$height = is_null($height) ? $width : $height;
|
||||||
} else {
|
} else {
|
||||||
// width or height not defined (resume with original values)
|
// width or height not defined (resume with original values)
|
||||||
throw new Exception\ImageDimensionException('width or height needs to be defined');
|
throw new Exception\DimensionOutOfBoundsException(
|
||||||
|
'width or height needs to be defined'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ausschnitt berechnen
|
// ausschnitt berechnen
|
||||||
@@ -796,12 +806,15 @@ class Image
|
|||||||
*/
|
*/
|
||||||
public function opacity($transparency)
|
public function opacity($transparency)
|
||||||
{
|
{
|
||||||
if ($transparency >= 0 && $transparency <= 100) {
|
if (is_numeric($transparency) && $transparency >= 0 && $transparency <= 100) {
|
||||||
$transparency = intval($transparency) / 100;
|
$transparency = intval($transparency) / 100;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception\ImageOpacityException('Opacity must be between 0 and 100');
|
throw new Exception\OpacityOutOfBoundsException('Opacity must be between 0 and 100');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
// http://stackoverflow.com/questions/2396415/what-does-new-self-mean-in-php
|
||||||
|
// --------------------------------------------------------------------
|
||||||
// create alpha mask
|
// create alpha mask
|
||||||
$alpha = new self(null, $this->width, $this->height);
|
$alpha = new self(null, $this->width, $this->height);
|
||||||
$alpha->fill(sprintf('rgba(0, 0, 0, %.1f)', $transparency));
|
$alpha->fill(sprintf('rgba(0, 0, 0, %.1f)', $transparency));
|
||||||
@@ -1044,18 +1057,18 @@ class Image
|
|||||||
* Changes the brightness of the current image
|
* Changes the brightness of the current image
|
||||||
*
|
*
|
||||||
* @param int $level [description]
|
* @param int $level [description]
|
||||||
|
*
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
public function brightness($level)
|
public function brightness($level)
|
||||||
{
|
{
|
||||||
// normalize level
|
if ($level < -100 || $level > 100) {
|
||||||
if ($level >= -100 && $level <= 100) {
|
throw new Exception\BrightnessOutOfBoundsException(
|
||||||
$level = $level * 2.55;
|
'Brightness level must be between -100 and +100'
|
||||||
} else {
|
);
|
||||||
throw new Exception\ImageBrightnessException('Brightness level must be between -100 and +100');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imagefilter($this->resource, IMG_FILTER_BRIGHTNESS, $level);
|
imagefilter($this->resource, IMG_FILTER_BRIGHTNESS, ($level * 2.55));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -1064,18 +1077,18 @@ class Image
|
|||||||
* Changes the contrast of the current image
|
* Changes the contrast of the current image
|
||||||
*
|
*
|
||||||
* @param int $level
|
* @param int $level
|
||||||
|
*
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
public function contrast($level)
|
public function contrast($level)
|
||||||
{
|
{
|
||||||
// normalize level
|
if ($level < -100 || $level > 100) {
|
||||||
if ($level >= -100 && $level <= 100) {
|
throw new Exception\ContrastOutOfBoundsException(
|
||||||
$level = $level * (-1);
|
'Contrast level must be between -100 and +100'
|
||||||
} else {
|
);
|
||||||
throw new Exception\ImageConstractException('Contrast level must be between -100 and +100');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imagefilter($this->resource, IMG_FILTER_CONTRAST, $level);
|
imagefilter($this->resource, IMG_FILTER_CONTRAST, ($level * -1));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -1387,12 +1400,19 @@ class Image
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Read Exif data from the current image
|
* Read Exif data from the current image
|
||||||
*
|
*
|
||||||
|
* Note: Windows PHP Users - in order to use this method you will need to
|
||||||
|
* enable the mbstring and exif extensions within the php.ini file.
|
||||||
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function exif($key = null)
|
public function exif($key = null)
|
||||||
{
|
{
|
||||||
|
if (!function_exists('exif_read_data')) {
|
||||||
|
throw new Exception\ExifFunctionsNotAvailableException;
|
||||||
|
}
|
||||||
|
|
||||||
$data = exif_read_data($this->dirname .'/'. $this->basename, 'EXIF', false);
|
$data = exif_read_data($this->dirname .'/'. $this->basename, 'EXIF', false);
|
||||||
|
|
||||||
if ( ! is_null($key)) {
|
if ( ! is_null($key)) {
|
||||||
@@ -1450,6 +1470,10 @@ class Image
|
|||||||
*/
|
*/
|
||||||
private function isBinary($input)
|
private function isBinary($input)
|
||||||
{
|
{
|
||||||
|
if (is_resource($input)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return ( ! ctype_print($input));
|
return ( ! ctype_print($input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1461,7 +1485,29 @@ class Image
|
|||||||
*/
|
*/
|
||||||
private function isImageResource($input)
|
private function isImageResource($input)
|
||||||
{
|
{
|
||||||
return (is_resource($input) && get_resource_type($input) == 'gd');
|
// --------------------------------------------------------------------
|
||||||
|
// There was a logical error in the program that wasn't considered.
|
||||||
|
// Namely, how should the program handle a valid resource handle
|
||||||
|
// that wasn't a valid image resource handle.
|
||||||
|
//
|
||||||
|
// Previously this method simply returned false if $input wasn't
|
||||||
|
// a valid image resource handle. But in the constructor, the next
|
||||||
|
// conditional passed the file handle to the Image::isBinary method.
|
||||||
|
// The Image::isBinary method only checked if the input didn't contain
|
||||||
|
// any printable characters which for a handle is true. So the program
|
||||||
|
// incorrectly assumed the file handle as a binary string causing errors.
|
||||||
|
// By throwing an exception for resource handles that are not of type
|
||||||
|
// 'gd', the program stop the futher processing of data, and the
|
||||||
|
// developer is given a descriptive exception.
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (is_resource($input)) {
|
||||||
|
if (get_resource_type($input) != 'gd') {
|
||||||
|
throw new Exception\InvalidImageResourceException;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1506,7 +1552,14 @@ class Image
|
|||||||
*/
|
*/
|
||||||
private function setImageInfoFromPath($path)
|
private function setImageInfoFromPath($path)
|
||||||
{
|
{
|
||||||
$info = getimagesize($path);
|
$info = @getimagesize($path);
|
||||||
|
|
||||||
|
if ($info === false) {
|
||||||
|
throw new Exception\InvalidImageTypeException(
|
||||||
|
"Wrong image type ({$this->type}) only use JPG, PNG or GIF images."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->width = $info[0];
|
$this->width = $info[0];
|
||||||
$this->height = $info[1];
|
$this->height = $info[1];
|
||||||
$this->type = $info[2];
|
$this->type = $info[2];
|
||||||
@@ -1530,7 +1583,9 @@ class Image
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception\InvalidImageTypeException("Wrong image type ({$this->type}) only use JPG, PNG or GIF images.");
|
throw new Exception\InvalidImageTypeException(
|
||||||
|
"Wrong image type ({$this->type}) only use JPG, PNG or GIF images."
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1556,7 +1611,17 @@ class Image
|
|||||||
*/
|
*/
|
||||||
private function setImageInfoFromString($string)
|
private function setImageInfoFromString($string)
|
||||||
{
|
{
|
||||||
$this->resource = imagecreatefromstring($string);
|
// Without the '@' passing in an invalid binary-safe string will
|
||||||
|
// cause PHP to raise a warning. (Which is fine in production since
|
||||||
|
// you should have display errors off. right?)
|
||||||
|
// So supress the warning, and then check if there was an error.
|
||||||
|
$resource = @imagecreatefromstring($string);
|
||||||
|
|
||||||
|
if ($resource === false) {
|
||||||
|
throw new Exception\InvalidImageDataStringException;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->resource = $resource;
|
||||||
$this->width = imagesx($this->resource);
|
$this->width = imagesx($this->resource);
|
||||||
$this->height = imagesy($this->resource);
|
$this->height = imagesy($this->resource);
|
||||||
$this->original['width'] = $this->width;
|
$this->original['width'] = $this->width;
|
||||||
|
@@ -56,6 +56,22 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertEquals($img->mime, 'image/jpeg');
|
$this->assertEquals($img->mime, 'image/jpeg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\ImageNotFoundException
|
||||||
|
*/
|
||||||
|
public function testConstructorWithInvalidPath()
|
||||||
|
{
|
||||||
|
$img = new Image('public/foo/bar/invalid_image_path.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\InvalidImageTypeException
|
||||||
|
*/
|
||||||
|
public function testContructorWithPathInvalidType()
|
||||||
|
{
|
||||||
|
$img = new Image('public/text.txt');
|
||||||
|
}
|
||||||
|
|
||||||
public function testConstructoWithString()
|
public function testConstructoWithString()
|
||||||
{
|
{
|
||||||
$data = file_get_contents('public/test.jpg');
|
$data = file_get_contents('public/test.jpg');
|
||||||
@@ -68,6 +84,17 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertEquals($img->height, 600);
|
$this->assertEquals($img->height, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\InvalidImageDataStringException
|
||||||
|
*/
|
||||||
|
public function testConstructionWithInvalidString()
|
||||||
|
{
|
||||||
|
// the semi-random string is base64_decoded to allow it to
|
||||||
|
// pass the isBinary conditional.
|
||||||
|
$data = base64_decode('6KKjdeyUAhRPNzxeYybZ');
|
||||||
|
$img = new Image($data);
|
||||||
|
}
|
||||||
|
|
||||||
public function testConstructorWithResource()
|
public function testConstructorWithResource()
|
||||||
{
|
{
|
||||||
$resource = imagecreatefromjpeg('public/test.jpg');
|
$resource = imagecreatefromjpeg('public/test.jpg');
|
||||||
@@ -80,6 +107,15 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertEquals($img->height, 600);
|
$this->assertEquals($img->height, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\InvalidImageResourceException
|
||||||
|
*/
|
||||||
|
public function testConstructorWithInvalidResource()
|
||||||
|
{
|
||||||
|
$resource = fopen('public/test.jpg', 'r+');
|
||||||
|
$img = new Image($resource);
|
||||||
|
}
|
||||||
|
|
||||||
public function testConstructorCanvas()
|
public function testConstructorCanvas()
|
||||||
{
|
{
|
||||||
$img = new Image(null, 800, 600);
|
$img = new Image(null, 800, 600);
|
||||||
@@ -285,6 +321,15 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertEquals($img->height, $original_height);
|
$this->assertEquals($img->height, $original_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\DimensionOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testResizeImageWithoutDimensions()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->resize();
|
||||||
|
}
|
||||||
|
|
||||||
public function testWidenImage()
|
public function testWidenImage()
|
||||||
{
|
{
|
||||||
$img = $this->getTestImage();
|
$img = $this->getTestImage();
|
||||||
@@ -497,6 +542,24 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertEquals('#ffa600', $img->pickColor(99, 99, 'hex'));
|
$this->assertEquals('#ffa600', $img->pickColor(99, 99, 'hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\DimensionOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testCropImageWithoutDimensions()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->crop(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\DimensionOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testCropImageWithNonNumericDimensions()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->crop('a', 'z');
|
||||||
|
}
|
||||||
|
|
||||||
public function testLegacyResize()
|
public function testLegacyResize()
|
||||||
{
|
{
|
||||||
// auto height
|
// auto height
|
||||||
@@ -564,6 +627,15 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertEquals($img->pickColor(95, 20, 'hex'), '#ffe8bf');
|
$this->assertEquals($img->pickColor(95, 20, 'hex'), '#ffe8bf');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\DimensionOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testGrabImageWithoutDimensions()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->grab();
|
||||||
|
}
|
||||||
|
|
||||||
public function testFlipImage()
|
public function testFlipImage()
|
||||||
{
|
{
|
||||||
$img = $this->getTestImage();
|
$img = $this->getTestImage();
|
||||||
@@ -889,6 +961,33 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertEquals($checkColor['a'], 0.5);
|
$this->assertEquals($checkColor['a'], 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\OpacityOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testOpacityTooHigh()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->opacity(101);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\OpacityOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testOpacityTooLow()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->opacity(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\OpacityOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testOpacityAlphaChar()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->opacity('a');
|
||||||
|
}
|
||||||
|
|
||||||
public function testMaskImage()
|
public function testMaskImage()
|
||||||
{
|
{
|
||||||
// simple image mask
|
// simple image mask
|
||||||
@@ -1396,6 +1495,24 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertInternalType('int', $color);
|
$this->assertInternalType('int', $color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\ImageColorException
|
||||||
|
*/
|
||||||
|
public function testParseColorInvalidRGBColor()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->parseColor('rgb()');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\ImageColorException
|
||||||
|
*/
|
||||||
|
public function testParseColorInvalidHexColor()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->parseColor('ab');
|
||||||
|
}
|
||||||
|
|
||||||
public function testBrightnessImage()
|
public function testBrightnessImage()
|
||||||
{
|
{
|
||||||
$img = $this->getTestImage();
|
$img = $this->getTestImage();
|
||||||
@@ -1404,6 +1521,24 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\BrightnessOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testBrightnessOutOfBoundsHigh()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->brightness(101);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\BrightnessOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testBrightnessOutOfBoundsLow()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->brightness(-101);
|
||||||
|
}
|
||||||
|
|
||||||
public function testContrastImage()
|
public function testContrastImage()
|
||||||
{
|
{
|
||||||
$img = $this->getTestImage();
|
$img = $this->getTestImage();
|
||||||
@@ -1412,6 +1547,24 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\ContrastOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testContrastOutOfBoundsHigh()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->contrast(101);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Intervention\Image\Exception\ContrastOutOfBoundsException
|
||||||
|
*/
|
||||||
|
public function testContrastOutOfBoundsLow()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->contrast(-101);
|
||||||
|
}
|
||||||
|
|
||||||
public function testEncode()
|
public function testEncode()
|
||||||
{
|
{
|
||||||
// default encoding
|
// default encoding
|
||||||
|
Reference in New Issue
Block a user