diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index ee214e9..966dcd8 100644
--- src/wp-includes/functions.php
+++ src/wp-includes/functions.php
@@ -2367,7 +2367,8 @@ function wp_get_image_mime( $file ) {
 	 */
 	try {
 		if ( is_callable( 'exif_imagetype' ) ) {
-			$mime = image_type_to_mime_type( exif_imagetype( $file ) );
+			$imagetype = exif_imagetype( $file );
+			$mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false;
 		} elseif ( function_exists( 'getimagesize' ) ) {
 			$imagesize = getimagesize( $file );
 			$mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
diff --git tests/phpunit/tests/functions.php tests/phpunit/tests/functions.php
index a3aba79..0c997d7 100644
--- tests/phpunit/tests/functions.php
+++ tests/phpunit/tests/functions.php
@@ -916,6 +916,18 @@ class Tests_Functions extends WP_UnitTestCase {
 	}
 
 	/**
+	 * @ticket 40017
+	 * @dataProvider _wp_get_image_mime
+	 */
+	public function test_wp_get_image_mime( $file, $expected ) {
+		if ( ! is_callable( 'exif_imagetype' ) && ! function_exists( 'getimagesize' ) ) {
+			$this->markTestSkipped( 'The exif PHP extension is not loaded.' );
+		}
+
+		$this->assertEquals( $expected, wp_get_image_mime( $file ) );
+	}
+
+	/**
 	 * @ticket 39550
 	 * @dataProvider _wp_check_filetype_and_ext_data
 	 */
@@ -993,6 +1005,38 @@ class Tests_Functions extends WP_UnitTestCase {
 		return $mimes;
 	}
 
+	public function _wp_get_image_mime() {
+		$data = array(
+			// Standard JPEG.
+			array(
+				DIR_TESTDATA . '/images/test-image.jpg',
+				'image/jpeg'
+			),
+			// Standard GIF.
+			array(
+				DIR_TESTDATA . '/images/test-image.gif',
+				'image/gif'
+			),
+			// Standard PNG.
+			array(
+				DIR_TESTDATA . '/images/test-image.png',
+				'image/png'
+			),
+			// Image with wrong extension.
+			array(
+				DIR_TESTDATA . '/images/test-image-mime-jpg.png',
+				'image/jpeg'
+			),
+			// Not an image.
+			array(
+				DIR_TESTDATA.'/uploads/dashicons.woff',
+				false
+			),
+		);
+
+		return $data;
+	}
+
 	public function _wp_check_filetype_and_ext_data() {
 		$data = array(
 			// Standard image.
