Skip to content

Commit

Permalink
Add detection for BMP files
Browse files Browse the repository at this point in the history
  • Loading branch information
0xC0000054 committed Apr 20, 2022
1 parent b9cecf1 commit 54ed0f1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/FormatDetection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace WebPFileType
{
internal static class FormatDetection
{
private static ReadOnlySpan<byte> BmpFileSignature => new byte[] { 0x42, 0x4D };

private static ReadOnlySpan<byte> Gif87aFileSignature => new byte[] { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 };

private static ReadOnlySpan<byte> Gif89aFileSignature => new byte[] { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61 };
Expand Down Expand Up @@ -109,6 +111,10 @@ private static string TryGetFileTypeName(ReadOnlySpan<byte> file)
{
name = "PNG";
}
else if (FileSignatureMatches(file, BmpFileSignature))
{
name = "BMP";
}
else if (IsGifFileSignature(file))
{
name = "GIF";
Expand Down

0 comments on commit 54ed0f1

Please sign in to comment.