mirror of
https://github.com/Intervention/image.git
synced 2025-08-19 04:01:30 +02:00
tiff encoding tests
This commit is contained in:
@@ -25,6 +25,13 @@ abstract class AbstractEncoder
|
||||
*/
|
||||
abstract protected function processGif();
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as TIFF string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function processTiff();
|
||||
|
||||
/**
|
||||
* Buffer of encode result data
|
||||
*
|
||||
@@ -69,16 +76,15 @@ abstract class AbstractEncoder
|
||||
$this->result = $this->processJpeg();
|
||||
break;
|
||||
|
||||
case 'tif':
|
||||
case 'tiff':
|
||||
case 'image/tiff':
|
||||
if (method_exists($this, 'processTiff')) {
|
||||
$this->result = $this->processTiff();
|
||||
break;
|
||||
}
|
||||
//fall through
|
||||
$this->result = $this->processTiff();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"Writing format ({$format}) is not supported."
|
||||
"Encoding format ({$format}) is not supported."
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@@ -54,4 +54,16 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as TIFF string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processTiff()
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"TIFF format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -46,6 +46,18 @@ class EncoderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('image/gif; charset=binary', $this->getMime($encoder->result));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Intervention\Image\Exception\NotSupportedException
|
||||
*/
|
||||
public function testProcessTiffGd()
|
||||
{
|
||||
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
|
||||
$encoder = new GdEncoder;
|
||||
$image = Mockery::mock('\Intervention\Image\Image');
|
||||
$img = $encoder->process($image, 'tif', 90);
|
||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||
}
|
||||
|
||||
public function testProcessUnknownWithMimeGd()
|
||||
{
|
||||
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
|
||||
@@ -107,6 +119,18 @@ class EncoderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('mock-gif', $encoder->result);
|
||||
}
|
||||
|
||||
public function testProcessTiffImagick()
|
||||
{
|
||||
$core = $this->getImagickMock('tiff');
|
||||
$encoder = new ImagickEncoder;
|
||||
$image = Mockery::mock('\Intervention\Image\Image');
|
||||
$image->shouldReceive('getCore')->once()->andReturn($core);
|
||||
$image->shouldReceive('setEncoded')->once()->andReturn($image);
|
||||
$img = $encoder->process($image, 'tiff', 90);
|
||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||
$this->assertEquals('mock-tiff', $encoder->result);
|
||||
}
|
||||
|
||||
public function testProcessUnknownWithMimeImagick()
|
||||
{
|
||||
$core = $this->getImagickMock('jpeg');
|
||||
|
Reference in New Issue
Block a user