Skip to content

Commit d6a0b9a

Browse files
authored
Add support for .tif/.tiff files (#32)
1 parent cae34bd commit d6a0b9a

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/ByteGuard.FileValidator/FileExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,15 @@ public static class FileExtensions
134134
/// Graphics Interchange Format.
135135
/// </summary>
136136
public const string Gif = ".gif";
137+
138+
/// <summary>
139+
/// Tag Image File Format.
140+
/// </summary>
141+
public const string Tif = ".tif";
142+
143+
/// <summary>
144+
/// Tag Image File Format.
145+
/// </summary>
146+
public const string Tiff = ".tiff";
137147
}
138148
}

src/ByteGuard.FileValidator/FileValidator.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,28 @@ public class FileValidator
265265
{
266266
new byte[] { 0x47, 0x49, 0x46, 0x38 }, // GIF8
267267
}
268+
},
269+
new FileDefinition
270+
{
271+
FileType = FileExtensions.Tif,
272+
ValidSignatures = new List<byte[]>
273+
{
274+
new byte[] { 0x49, 0x49, 0x2A, 0x00 }, // II*␀ (Intel byte order)
275+
new byte[] { 0x4D, 0x4D, 0x00, 0x2A }, // MM␀* (Motorola byte order)
276+
new byte[] { 0x49, 0x49, 0x2B, 0x00 }, // II+␀ (BigTIFF, Intel byte order)
277+
new byte[] { 0x4D, 0x4D, 0x00, 0x2B } // MM␀+ (BigTIFF, Motorola byte order)
278+
}
279+
},
280+
new FileDefinition
281+
{
282+
FileType = FileExtensions.Tiff,
283+
ValidSignatures = new List<byte[]>
284+
{
285+
new byte[] { 0x49, 0x49, 0x2A, 0x00 }, // II*␀ (Intel byte order)
286+
new byte[] { 0x4D, 0x4D, 0x00, 0x2A }, // MM␀* (Motorola byte order)
287+
new byte[] { 0x49, 0x49, 0x2B, 0x00 }, // II+␀ (BigTIFF, Intel byte order)
288+
new byte[] { 0x4D, 0x4D, 0x00, 0x2B } // MM␀+ (BigTIFF, Motorola byte order)
289+
}
268290
}
269291
};
270292

0 commit comments

Comments
 (0)