mirror of
https://github.com/Intervention/image.git
synced 2025-08-20 04:31:24 +02:00
tiff encoding tests
This commit is contained in:
@@ -25,6 +25,13 @@ abstract class AbstractEncoder
|
|||||||
*/
|
*/
|
||||||
abstract protected function processGif();
|
abstract protected function processGif();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes and returns encoded image as TIFF string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract protected function processTiff();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Buffer of encode result data
|
* Buffer of encode result data
|
||||||
*
|
*
|
||||||
@@ -69,16 +76,15 @@ abstract class AbstractEncoder
|
|||||||
$this->result = $this->processJpeg();
|
$this->result = $this->processJpeg();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'tif':
|
||||||
case 'tiff':
|
case 'tiff':
|
||||||
case 'image/tiff':
|
case 'image/tiff':
|
||||||
if (method_exists($this, 'processTiff')) {
|
|
||||||
$this->result = $this->processTiff();
|
$this->result = $this->processTiff();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
//fall through
|
|
||||||
default:
|
default:
|
||||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||||
"Writing format ({$format}) is not supported."
|
"Encoding format ({$format}) is not supported."
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -54,4 +54,16 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
|||||||
|
|
||||||
return $buffer;
|
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));
|
$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()
|
public function testProcessUnknownWithMimeGd()
|
||||||
{
|
{
|
||||||
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
|
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
|
||||||
@@ -107,6 +119,18 @@ class EncoderTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('mock-gif', $encoder->result);
|
$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()
|
public function testProcessUnknownWithMimeImagick()
|
||||||
{
|
{
|
||||||
$core = $this->getImagickMock('jpeg');
|
$core = $this->getImagickMock('jpeg');
|
||||||
|
Reference in New Issue
Block a user