TiffDetector.cs 1.1 KB

12345678910111213141516171819202122232425262728
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Reflection;
  5. using Masuit.Tools.Mime;
  6. namespace Masuit.Tools.Files.FileDetector.Detectors;
  7. [FormatCategory(FormatCategory.Image)]
  8. internal sealed class TiffDetector : AbstractSignatureDetector
  9. {
  10. private static readonly SignatureInformation[] TiffSignatureInfo = {
  11. new () { Position = 0, Signature = "III"u8.ToArray() },
  12. new () { Position = 0, Signature = new byte [] { 0x49, 0x49, 0x2A, 0x00 } },
  13. new () { Position = 0, Signature = new byte [] { 0x4D, 0x4D, 0x00, 0x2A } },
  14. new () { Position = 0, Signature = new byte [] { 0x4D, 0x4D, 0x00, 0x2B } },
  15. };
  16. public override string Extension => "tif";
  17. public override string MimeType => new MimeMapper().GetMimeFromExtension("." + Extension);
  18. public override List<FormatCategory> FormatCategories => GetType().GetCustomAttributes<FormatCategoryAttribute>().Select(a => a.Category).ToList();
  19. protected override SignatureInformation[] SignatureInformations => TiffSignatureInfo;
  20. public override string ToString() => "Tagged Image File Format Detector";
  21. }