GifDecoder
A class for decoding GIF files. Other than cached frames, configured with cacheFrameInterval, all frames are decoded only when requested, minimizing memory usage.
Usage:
// Obtain a Path to read the GIF data from
val path: Path = ...
val data = path.asRandomAccess()
val decoder = GifDecoder(data)
// Read a single frame by index
val frame1 = decoder[0]
// Read a single frame by timestamp
val frame2 = decoder[2.seconds]
// Read all frames
decoder.asSequence().forEach { frame ->
// Process each frame
}
decoder.close()Parameters
The RandomAccessData to read the GIF data from.
The interval at which frames are cached. Setting this to a higher value can improve random access speed with get, but increases memory usage.
Set to 1 to cache every frame, making random access speed similar to that of Array. Warning: this can cause the decoder to use a large amount of memory.
Set to 0 to disable caching, which will decrease the initial load time and minimize memory usage. Disable caching if you only need to read frames sequentially using asSequence or get in increasing order of their index or timestamp.
Throws
If the GIF data is invalid and cannot be decoded.
If an I/O error occurs.
A class for decoding GIF files. Other than cached frames, configured with cacheFrameInterval, all frames are decoded only when requested, minimizing memory usage.
Usage:
// Obtain a Path to read the GIF data from
val path: Path = ...
val data = path.asRandomAccess()
val decoder = GifDecoder(data)
// Read a single frame by index
val frame1 = decoder[0]
// Read a single frame by timestamp
val frame2 = decoder[2.seconds]
// Read all frames
decoder.asSequence().forEach { frame ->
// Process each frame
}
decoder.close()Parameters
The RandomAccessData to read the GIF data from.
The interval at which frames are cached. Setting this to a higher value can improve random access speed with get, but increases memory usage.
Set to 1 to cache every frame, making random access speed similar to that of Array. Warning: this can cause the decoder to use a large amount of memory.
Set to 0 to disable caching, which will decrease the initial load time and minimize memory usage. Disable caching if you only need to read frames sequentially using asSequence or get in increasing order of their index or timestamp.
Throws
If the GIF data is invalid and cannot be decoded.
If an I/O error occurs.
A class for decoding GIF files. Other than cached frames, configured with cacheFrameInterval, all frames are decoded only when requested, minimizing memory usage.
Usage:
// Obtain a Path to read the GIF data from
val path: Path = ...
val data = path.asRandomAccess()
val decoder = GifDecoder(data)
// Read a single frame by index
val frame1 = decoder[0]
// Read a single frame by timestamp
val frame2 = decoder[2.seconds]
// Read all frames
decoder.asSequence().forEach { frame ->
// Process each frame
}
decoder.close()Parameters
The RandomAccessData to read the GIF data from.
The interval at which frames are cached. Setting this to a higher value can improve random access speed with get, but increases memory usage.
Set to 1 to cache every frame, making random access speed similar to that of Array. Warning: this can cause the decoder to use a large amount of memory.
Set to 0 to disable caching, which will decrease the initial load time and minimize memory usage. Disable caching if you only need to read frames sequentially using asSequence or get in increasing order of their index or timestamp.
Throws
If the GIF data is invalid and cannot be decoded.
If an I/O error occurs.
Constructors
Constructs a GifDecoder, reading GIF data from a file.
Constructs a GifDecoder, reading GIF data from a file.
Constructs a GifDecoder, reading GIF data from a byte array.
Constructs a GifDecoder, reading GIF data from a byte array.
Constructs a GifDecoder, reading GIF data from a byte array.
Properties
The comment in the GIF comment block metadata. This can be an empty string if no comment is present.
The comment in the GIF comment block metadata. This can be an empty string if no comment is present.
The total duration of the GIF, which is the sum of all frame durations.
The total duration of the GIF, which is the sum of all frame durations.
The total number of frames in the GIF.
The total number of frames in the GIF.
The total number of frames in the GIF.
The total duration of the GIF, which is the sum of all frame durations.
Functions
Returns a List view of all frames in the GIF. The returned list's random access speed depends on the cacheFrameInterval.
Returns a List view of all frames in the GIF. The returned list's random access speed depends on the cacheFrameInterval.
Returns a List view of all frames in the GIF. The returned list's random access speed depends on the cacheFrameInterval.
Reads a frame by its timestamp.
Reads a frame by its index.
Reads a frame by its index.
Reads a frame by its timestamp.
Reads a frame by its index.
Reads a frame by its timestamp.