Remove unused mimetype detection method in OC_Image
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
645fc993c2
commit
dbb034f903
|
@ -62,22 +62,6 @@ class OC_Image implements \OCP\IImage {
|
|||
/** @var array */
|
||||
private $exif;
|
||||
|
||||
/**
|
||||
* Get mime type for an image file.
|
||||
*
|
||||
* @param string|null $filePath The path to a local image file.
|
||||
* @return string The mime type if the it could be determined, otherwise an empty string.
|
||||
*/
|
||||
static public function getMimeTypeForFile($filePath) {
|
||||
// exif_imagetype throws "read error!" if file is less than 12 byte
|
||||
if ($filePath !== null && filesize($filePath) > 11) {
|
||||
$imageType = exif_imagetype($filePath);
|
||||
} else {
|
||||
$imageType = false;
|
||||
}
|
||||
return $imageType ? image_type_to_mime_type($imageType) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
|
@ -19,20 +19,6 @@ class ImageTest extends \Test\TestCase {
|
|||
parent::tearDownAfterClass();
|
||||
}
|
||||
|
||||
public function testGetMimeTypeForFile() {
|
||||
$mimetype = \OC_Image::getMimeTypeForFile(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertEquals('image/png', $mimetype);
|
||||
|
||||
$mimetype = \OC_Image::getMimeTypeForFile(OC::$SERVERROOT.'/tests/data/testimage.jpg');
|
||||
$this->assertEquals('image/jpeg', $mimetype);
|
||||
|
||||
$mimetype = \OC_Image::getMimeTypeForFile(OC::$SERVERROOT.'/tests/data/testimage.gif');
|
||||
$this->assertEquals('image/gif', $mimetype);
|
||||
|
||||
$mimetype = \OC_Image::getMimeTypeForFile(null);
|
||||
$this->assertEquals('', $mimetype);
|
||||
}
|
||||
|
||||
public function testConstructDestruct() {
|
||||
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png');
|
||||
$this->assertInstanceOf('\OC_Image', $img);
|
||||
|
@ -337,7 +323,6 @@ class ImageTest extends \Test\TestCase {
|
|||
$tempFile = tempnam(sys_get_temp_dir(), 'img-test');
|
||||
|
||||
$img->save($tempFile, $mimeType);
|
||||
$actualMimeType = \OC_Image::getMimeTypeForFile($tempFile);
|
||||
$this->assertEquals($mimeType, $actualMimeType);
|
||||
$this->assertEquals($mimeType, image_type_to_mime_type(exif_imagetype($tempFile)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue