Skip to content

Commit a390fc6

Browse files
committed
make GetTiffFrameCountFast also count Thumbnail since ImageSharp cannot open tiff is it have Thumbnail
1 parent 347fa9f commit a390fc6

1 file changed

Lines changed: 2 additions & 21 deletions

File tree

  • IronSoftware.Drawing/IronSoftware.Drawing.Common

IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,20 +2810,7 @@ private int GetTiffFrameCountFast()
28102810
using var tiff = Tiff.ClientOpen("in-memory", "r", tiffStream, new TiffStream());
28112811
if (tiff == null) return 1; // Default to single frame if can't read
28122812

2813-
short frameCount = tiff.NumberOfDirectories();
2814-
2815-
// Filter out thumbnails like in InternalLoadTiff
2816-
short actualFrames = 0;
2817-
for (short i = 0; i < frameCount; i++)
2818-
{
2819-
tiff.SetDirectory(i);
2820-
if (!IsThumbnail(tiff))
2821-
{
2822-
actualFrames++;
2823-
}
2824-
}
2825-
2826-
return actualFrames > 0 ? actualFrames : 1;
2813+
return tiff.NumberOfDirectories();
28272814
}
28282815
catch
28292816
{
@@ -2934,14 +2921,8 @@ private Lazy<IReadOnlyList<Image>> OpenImageToImageSharp(bool preserveOriginalFo
29342921
}
29352922
catch (Exception e)
29362923
{
2937-
try
2938-
{
2939-
return backup.Invoke();
2940-
}
2941-
catch (Exception) {
2942-
throw new NotSupportedException(
2924+
throw new NotSupportedException(
29432925
"Image could not be loaded. File format is not supported.", e);
2944-
}
29452926
}
29462927
});
29472928
}

0 commit comments

Comments
 (0)