1313using SixLabors . ImageSharp . Memory ;
1414using SixLabors . ImageSharp . Metadata ;
1515using SixLabors . ImageSharp . Metadata . Profiles . Exif ;
16- using SixLabors . ImageSharp . Metadata . Profiles . Xmp ;
1716using SixLabors . ImageSharp . PixelFormats ;
1817
1918namespace SixLabors . ImageSharp . Formats . Tiff
@@ -33,6 +32,11 @@ internal class TiffDecoderCore : IImageDecoderInternals
3332 /// </summary>
3433 private readonly bool ignoreMetadata ;
3534
35+ /// <summary>
36+ /// Gets the decoding mode for multi-frame images
37+ /// </summary>
38+ private FrameDecodingMode decodingMode ;
39+
3640 /// <summary>
3741 /// The stream to decode from.
3842 /// </summary>
@@ -59,6 +63,7 @@ public TiffDecoderCore(Configuration configuration, ITiffDecoderOptions options)
5963
6064 this . Configuration = configuration ?? Configuration . Default ;
6165 this . ignoreMetadata = options . IgnoreMetadata ;
66+ this . decodingMode = options . DecodingMode ;
6267 this . memoryAllocator = this . Configuration . MemoryAllocator ;
6368 }
6469
@@ -160,11 +165,16 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
160165 cancellationToken . ThrowIfCancellationRequested ( ) ;
161166 ImageFrame < TPixel > frame = this . DecodeFrame < TPixel > ( ifd , cancellationToken ) ;
162167 frames . Add ( frame ) ;
168+
169+ if ( this . decodingMode is FrameDecodingMode . First )
170+ {
171+ break ;
172+ }
163173 }
164174
165175 ImageMetadata metadata = TiffDecoderMetadataCreator . Create ( frames , this . ignoreMetadata , reader . ByteOrder , reader . IsBigTiff ) ;
166176
167- // TODO: Tiff frames can have different sizes
177+ // TODO: Tiff frames can have different sizes.
168178 ImageFrame < TPixel > root = frames [ 0 ] ;
169179 this . Dimensions = root . Size ( ) ;
170180 foreach ( ImageFrame < TPixel > frame in frames )
0 commit comments