diff --git a/src/ImageSharp/Formats/Tiff/TiffConfigurationModule.cs b/src/ImageSharp/Formats/Tiff/TiffConfigurationModule.cs
index 6564834354..cc97da5bbc 100644
--- a/src/ImageSharp/Formats/Tiff/TiffConfigurationModule.cs
+++ b/src/ImageSharp/Formats/Tiff/TiffConfigurationModule.cs
@@ -13,9 +13,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
{
configuration.ImageFormatsManager.SetEncoder(TiffFormat.Instance, new TiffEncoder());
configuration.ImageFormatsManager.SetDecoder(TiffFormat.Instance, new TiffDecoder());
- configuration.ImageFormatsManager.AddImageFormatDetector(new TiffImageFormatDetector(false));
-
- configuration.ImageFormatsManager.AddImageFormatDetector(new TiffImageFormatDetector(true));
+ configuration.ImageFormatsManager.AddImageFormatDetector(new TiffImageFormatDetector());
}
}
}
diff --git a/src/ImageSharp/Formats/Tiff/TiffImageFormatDetector.cs b/src/ImageSharp/Formats/Tiff/TiffImageFormatDetector.cs
index 5755b306a0..51280b4bf3 100644
--- a/src/ImageSharp/Formats/Tiff/TiffImageFormatDetector.cs
+++ b/src/ImageSharp/Formats/Tiff/TiffImageFormatDetector.cs
@@ -10,16 +10,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff
///
public sealed class TiffImageFormatDetector : IImageFormatDetector
{
- private readonly bool isBigTiff;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// if set to true is BigTiff.
- public TiffImageFormatDetector(bool isBigTiff) => this.isBigTiff = isBigTiff;
-
///
- public int HeaderSize => this.isBigTiff ? 8 : 4;
+ public int HeaderSize => 8;
///
public IImageFormat DetectFormat(ReadOnlySpan header)
@@ -39,39 +31,32 @@ namespace SixLabors.ImageSharp.Formats.Tiff
if (header[0] == 0x49 && header[1] == 0x49)
{
// Little-endian
- if (this.isBigTiff is false)
+ if (header[2] == 0x2A && header[3] == 0x00)
{
- if (header[2] == 0x2A && header[3] == 0x00)
- {
- return true;
- }
+ // tiff
+ return true;
}
- else
+ else if (header[2] == 0x2B && header[3] == 0x00
+ && header[4] == 8 && header[5] == 0 && header[6] == 0 && header[7] == 0)
{
- if (header[2] == 0x2B && header[3] == 0x00
- && header[4] == 8 && header[5] == 0 && header[6] == 0 && header[7] == 0)
- {
- return true;
- }
+ // big tiff
+ return true;
}
}
else if (header[0] == 0x4D && header[1] == 0x4D)
{
// Big-endian
- if (this.isBigTiff is false)
+ if (header[2] == 0 && header[3] == 0x2A)
{
- if (header[2] == 0 && header[3] == 0x2A)
- {
- return true;
- }
+ // tiff
+ return true;
}
else
+ if (header[2] == 0 && header[3] == 0x2B
+ && header[4] == 0 && header[5] == 8 && header[6] == 0 && header[7] == 0)
{
- if (header[2] == 0 && header[3] == 0x2B
- && header[4] == 0 && header[5] == 8 && header[6] == 0 && header[7] == 0)
- {
- return true;
- }
+ // big tiff
+ return true;
}
}
}