Add magic numbers for WebP (#54)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b77b2ac..52c625f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.0.1
+
+* Add image/webp mimeType lookup by header bytes.
+
# 1.0.0
* Stable null safety release.
diff --git a/lib/src/magic_number.dart b/lib/src/magic_number.dart
index 9db370f..78255c5 100644
--- a/lib/src/magic_number.dart
+++ b/lib/src/magic_number.dart
@@ -65,4 +65,37 @@
0xFF
]),
MagicNumber('model/gltf-binary', [0x46, 0x54, 0x6C, 0x67]),
+
+ /// The WebP file format is based on the RIFF document format.
+ /// -> 4 bytes have the ASCII characters 'R' 'I' 'F' 'F'.
+ /// -> 4 bytes indicating the size of the file
+ /// -> 4 bytes have the ASCII characters 'W' 'E' 'B' 'P'.
+ /// https://developers.google.com/speed/webp/docs/riff_container
+ MagicNumber('image/webp', [
+ 0x52,
+ 0x49,
+ 0x46,
+ 0x46,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x57,
+ 0x45,
+ 0x42,
+ 0x50
+ ], mask: [
+ 0xFF,
+ 0xFF,
+ 0xFF,
+ 0xFF,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0xFF,
+ 0xFF,
+ 0xFF,
+ 0xFF
+ ])
];
diff --git a/pubspec.yaml b/pubspec.yaml
index 5d796ae..d1b8430 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: mime
-version: 1.0.0
+version: 1.0.1
description: >-
Utilities for handling media (MIME) types, including determining a type from
diff --git a/test/mime_type_test.dart b/test/mime_type_test.dart
index 4dfdb13..e02e0af 100644
--- a/test/mime_type_test.dart
+++ b/test/mime_type_test.dart
@@ -40,6 +40,7 @@
_expectMimeType('file.pdf', 'application/pdf');
_expectMimeType('file.tiff', 'image/tiff');
_expectMimeType('file.tif', 'image/tiff');
+ _expectMimeType('file.webp', 'image/webp');
});
test('unknown-mime-type', () {
@@ -87,6 +88,20 @@
0x70,
0x35
]);
+ _expectMimeType('file', 'image/webp', headerBytes: [
+ 0x52,
+ 0x49,
+ 0x46,
+ 0x46,
+ 0xE2,
+ 0x4A,
+ 0x01,
+ 0x00,
+ 0x57,
+ 0x45,
+ 0x42,
+ 0x50
+ ]);
});
});