Merge pull request #7295 from nextcloud/remove-unused-method

Remove unused mimetype detection method in OC_Image
This commit is contained in:
Lukas Reschke 2017-11-27 11:55:20 +01:00 committed by GitHub
commit fb1a92b07d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 32 deletions

View File

@ -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.
*

View File

@ -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)));
}
}