Skip to content

Commit

Permalink
Remove unused mimetype detection method in OC_Image
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <[email protected]>
  • Loading branch information
MorrisJobke committed Nov 27, 2017
1 parent 645fc99 commit dbb034f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
16 changes: 0 additions & 16 deletions lib/private/legacy/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
17 changes: 1 addition & 16 deletions tests/lib/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ public static function tearDownAfterClass() {
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);
Expand Down Expand Up @@ -337,7 +323,6 @@ public function testConvert($mimeType) {
$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)));
}
}

0 comments on commit dbb034f

Please sign in to comment.