diff options
-rw-r--r-- | lib/private/legacy/image.php | 16 | ||||
-rw-r--r-- | tests/lib/ImageTest.php | 17 |
2 files changed, 1 insertions, 32 deletions
diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php index fe9f054f5d4..a7d702ac032 100644 --- a/lib/private/legacy/image.php +++ b/lib/private/legacy/image.php @@ -63,22 +63,6 @@ class OC_Image implements \OCP\IImage { 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. * * @param resource|string $imageRef The path to a local file, a base64 encoded string or a resource created by diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php index b7255ccdbd6..b4cb57f3787 100644 --- a/tests/lib/ImageTest.php +++ b/tests/lib/ImageTest.php @@ -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))); } } |