Jpeg2000Detector.cs 927 B

12345678910111213141516171819202122232425
  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 Jpeg2000Detector : AbstractSignatureDetector
  9. {
  10. private static readonly SignatureInformation[] JpegSignatureInfo = {
  11. new() { Position = 0, Signature = new byte [] { 0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20 } },
  12. };
  13. public override string Extension => "jp2";
  14. protected override SignatureInformation[] SignatureInformations => JpegSignatureInfo;
  15. public override string MimeType => new MimeMapper().GetMimeFromExtension("." + Extension);
  16. public override List<FormatCategory> FormatCategories => GetType().GetCustomAttributes<FormatCategoryAttribute>().Select(a => a.Category).ToList();
  17. public override string ToString() => "JPEG2000 Detector";
  18. }