1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-31 01:29:51 +02:00

added mime type property

This commit is contained in:
Oliver Vogel
2013-03-25 18:03:34 +01:00
parent 7a7fcbba54
commit 790418dad7
2 changed files with 16 additions and 1 deletions

View File

@@ -63,6 +63,13 @@ class Image
*/
public $filename;
/**
* MIME type of image
*
* @var string
*/
public $mimetype;
/**
* Attributes of the original created image
*
@@ -184,7 +191,11 @@ class Image
$this->filename = $info['filename'];
// set image info
list($this->width, $this->height, $this->type) = @getimagesize($path);
$info = getimagesize($path);
$this->width = $info[0];
$this->height = $info[1];
$this->type = $info[2];
$this->mimetype = $info['mime'];
// set resource
switch ($this->type) {

View File

@@ -22,6 +22,7 @@ class ImageTest extends PHPUnit_Framework_Testcase
$this->assertEquals($img->basename, 'test.jpg');
$this->assertEquals($img->extension, 'jpg');
$this->assertEquals($img->filename, 'test');
$this->assertEquals($img->mimetype, 'image/jpeg');
$img = new Image(null, 800, 600);
$this->assertInstanceOf('Intervention\Image\Image', $img);
@@ -45,6 +46,7 @@ class ImageTest extends PHPUnit_Framework_Testcase
$this->assertEquals($img->basename, 'test.jpg');
$this->assertEquals($img->extension, 'jpg');
$this->assertEquals($img->filename, 'test');
$this->assertEquals($img->mimetype, 'image/jpeg');
}
public function testCreationFromFile()
@@ -59,6 +61,7 @@ class ImageTest extends PHPUnit_Framework_Testcase
$this->assertEquals($img->basename, 'test.jpg');
$this->assertEquals($img->extension, 'jpg');
$this->assertEquals($img->filename, 'test');
$this->assertEquals($img->mimetype, 'image/jpeg');
}
public function testResizeImage()
@@ -1074,6 +1077,7 @@ class ImageTest extends PHPUnit_Framework_Testcase
$this->assertEquals($img->basename, 'test.jpg');
$this->assertEquals($img->extension, 'jpg');
$this->assertEquals($img->filename, 'test');
$this->assertEquals($img->mimetype, 'image/jpeg');
}
public function testStaticCallCanvas()