Package-level declarations

Types

Link copied to clipboard
abstract class AsyncGifEncoder(sink: Sink, colorDifferenceTolerance: Double, quantizedColorDifferenceTolerance: Double, loopCount: Int, maxColors: Int, colorQuantizer: ColorQuantizer, colorSimilarityChecker: ColorSimilarityChecker, comment: String, transparentAlphaThreshold: Int, alphaFill: Int, cropTransparent: Boolean, minimumFrameDurationCentiseconds: Int, maxConcurrency: Int, coroutineScope: CoroutineScope) : SuspendClosable

An abstract class for implementing GIF encoders that encode frames asynchronously.

Link copied to clipboard
fun interface ColorQuantizer

Interface for color quantization algorithms.

Link copied to clipboard

Interface for checking the similarity between two RGB colors.

Link copied to clipboard
interface ColorTable

Interface representing a color table used for color quantization.

Link copied to clipboard

Indicates the way in which a frame is to be treated after being displayed.

Link copied to clipboard
actual data class FrameInfo(val duration: Duration, val timestamp: Duration) : Comparable<FrameInfo>

Information about a single frame.

expect class FrameInfo(duration: Duration, timestamp: Duration) : Comparable<FrameInfo>

Information about a single frame.

actual data class FrameInfo(val duration: Duration, val timestamp: Duration) : Comparable<FrameInfo>

Information about a single frame.

Link copied to clipboard
actual class GifDecoder(data: RandomAccessData, cacheFrameInterval: Int) : AutoCloseable

A class for decoding GIF files. Other than cached frames, configured with cacheFrameInterval, all frames are decoded only when requested, minimizing memory usage.

expect class GifDecoder(data: RandomAccessData, cacheFrameInterval: Int = DEFAULT_GIF_CACHE_FRAME_INTERVAL) : AutoCloseable

A class for decoding GIF files. Other than cached frames, configured with cacheFrameInterval, all frames are decoded only when requested, minimizing memory usage.

actual class GifDecoder(data: RandomAccessData, cacheFrameInterval: Int) : AutoCloseable

A class for decoding GIF files. Other than cached frames, configured with cacheFrameInterval, all frames are decoded only when requested, minimizing memory usage.

Link copied to clipboard
actual class GifEncoder @JvmOverloads constructor(sink: Sink, colorDifferenceTolerance: Double, quantizedColorDifferenceTolerance: Double, loopCount: Int, maxColors: Int, colorQuantizer: ColorQuantizer, colorSimilarityChecker: ColorSimilarityChecker, comment: String, transparentAlphaThreshold: Int, alphaFill: Int, cropTransparent: Boolean, minimumFrameDurationCentiseconds: Int, onFrameWritten: (framesWritten: Int, writtenDuration: Duration) -> Unit) : AutoCloseable

A class for encoding GIF files. The dimensions of the created GIF are determined by the first frame written. Subsequent frames will have the same dimensions as the first frame, cropping or padding the frame to fit if necessary. The encoder must be closed after use to ensure all data is written correctly.

expect class GifEncoder constructor(sink: Sink, colorDifferenceTolerance: Double = 0.0, quantizedColorDifferenceTolerance: Double = -1.0, loopCount: Int = 0, maxColors: Int = GIF_MAX_COLORS, colorQuantizer: ColorQuantizer = ColorQuantizer.NEU_QUANT, colorSimilarityChecker: ColorSimilarityChecker = ColorSimilarityChecker.EUCLIDEAN_LUMINANCE_WEIGHTING, comment: String = "", transparentAlphaThreshold: Int = 20, alphaFill: Int = -1, cropTransparent: Boolean = true, minimumFrameDurationCentiseconds: Int = GIF_MINIMUM_FRAME_DURATION_CENTISECONDS, onFrameWritten: (framesWritten: Int, writtenDuration: Duration) -> Unit = { _, _ -> }) : AutoCloseable

A class for encoding GIF files. The dimensions of the created GIF are determined by the first frame written. Subsequent frames will have the same dimensions as the first frame, cropping or padding the frame to fit if necessary. The encoder must be closed after use to ensure all data is written correctly.

actual class GifEncoder @JvmOverloads constructor(sink: Sink, colorDifferenceTolerance: Double, quantizedColorDifferenceTolerance: Double, loopCount: Int, maxColors: Int, colorQuantizer: ColorQuantizer, colorSimilarityChecker: ColorSimilarityChecker, comment: String, transparentAlphaThreshold: Int, alphaFill: Int, cropTransparent: Boolean, minimumFrameDurationCentiseconds: Int, onFrameWritten: (framesWritten: Int, writtenDuration: Duration) -> Unit) : AutoCloseable

A class for encoding GIF files. The dimensions of the created GIF are determined by the first frame written. Subsequent frames will have the same dimensions as the first frame, cropping or padding the frame to fit if necessary. The encoder must be closed after use to ensure all data is written correctly.

actual class GifEncoder constructor(sink: Sink, colorDifferenceTolerance: Double, quantizedColorDifferenceTolerance: Double, loopCount: Int, maxColors: Int, colorQuantizer: ColorQuantizer, colorSimilarityChecker: ColorSimilarityChecker, comment: String, transparentAlphaThreshold: Int, alphaFill: Int, cropTransparent: Boolean, minimumFrameDurationCentiseconds: Int, onFrameWritten: (framesWritten: Int, writtenDuration: Duration) -> Unit) : AutoCloseable

A class for encoding GIF files. The dimensions of the created GIF are determined by the first frame written. Subsequent frames will have the same dimensions as the first frame, cropping or padding the frame to fit if necessary. The encoder must be closed after use to ensure all data is written correctly.

Link copied to clipboard
actual class GifEncoderBuilder(sink: Sink)

A builder for creating GifEncoder and ParallelGifEncoders.

expect class GifEncoderBuilder(sink: Sink)

A builder for creating GifEncoders.

actual class GifEncoderBuilder(sink: Sink)

A builder for creating GifEncoders.

actual class GifEncoderBuilder(sink: Sink)

A builder for creating GifEncoders.

Link copied to clipboard
data class Image(val argb: IntArray, val width: Int, val height: Int, val empty: Boolean = false)

Represents an image with pixel data in ARGB format.

Link copied to clipboard
actual data class ImageFrame(val argb: IntArray, val width: Int, val height: Int, val duration: Duration, val timestamp: Duration, val index: Int) : Comparable<ImageFrame>

Stores a single frame's data.

expect class ImageFrame(argb: IntArray, width: Int, height: Int, duration: Duration, timestamp: Duration, index: Int) : Comparable<ImageFrame>

Stores a single frame's data.

actual data class ImageFrame(val argb: IntArray, val width: Int, val height: Int, val duration: Duration, val timestamp: Duration, val index: Int) : Comparable<ImageFrame>

Stores a single frame's data.

actual data class ImageFrame(val argb: IntArray, val width: Int, val height: Int, val duration: Duration, val timestamp: Duration, val index: Int) : Comparable<ImageFrame>

Stores a single frame's data.

Link copied to clipboard
class InvalidGifException(message: String, cause: Throwable? = null) : RuntimeException

Exception thrown when a GIF file is invalid and cannot be decoded.

Link copied to clipboard

A callback that is invoked after a frame is written, providing the number of frames written and the total duration written so far. This can be used to track progress or update a UI.

Link copied to clipboard
actual class ParallelGifEncoder @JvmOverloads constructor(sink: Sink, colorDifferenceTolerance: Double, quantizedColorDifferenceTolerance: Double, loopCount: Int, maxColors: Int, colorQuantizer: ColorQuantizer, colorSimilarityChecker: ColorSimilarityChecker, comment: String, transparentAlphaThreshold: Int, alphaFill: Int, cropTransparent: Boolean, minimumFrameDurationCentiseconds: Int, maxConcurrency: Int, coroutineScope: CoroutineScope, ioContext: CoroutineContext, onFrameWritten: suspend (framesWritten: Int, writtenDuration: Duration) -> Unit) : SuspendClosable

A class for encoding GIF files. This encoder supports writing multiple frames in parallel. The dimensions of the created GIF are determined by the first frame written. Subsequent frames will have the same dimensions as the first frame, cropping or padding the frame to fit if necessary. The encoder must be closed after use to ensure all data is written correctly.

actual class ParallelGifEncoder @JvmOverloads constructor(sink: Sink, colorDifferenceTolerance: Double, quantizedColorDifferenceTolerance: Double, loopCount: Int, maxColors: Int, colorQuantizer: ColorQuantizer, colorSimilarityChecker: ColorSimilarityChecker, comment: String, transparentAlphaThreshold: Int, alphaFill: Int, cropTransparent: Boolean, minimumFrameDurationCentiseconds: Int, maxConcurrency: Int, coroutineScope: CoroutineScope, ioContext: CoroutineContext, onFrameWritten: suspend (framesWritten: Int, writtenDuration: Duration) -> Unit) : SuspendClosable

A class for encoding GIF files. This encoder supports writing multiple frames in parallel. The dimensions of the created GIF are determined by the first frame written. Subsequent frames will have the same dimensions as the first frame, cropping or padding the frame to fit if necessary. The encoder must be closed after use to ensure all data is written correctly.

actual class ParallelGifEncoder constructor(sink: Sink, colorDifferenceTolerance: Double, quantizedColorDifferenceTolerance: Double, loopCount: Int, maxColors: Int, colorQuantizer: ColorQuantizer, colorSimilarityChecker: ColorSimilarityChecker, comment: String, transparentAlphaThreshold: Int, alphaFill: Int, cropTransparent: Boolean, minimumFrameDurationCentiseconds: Int, maxConcurrency: Int, coroutineScope: CoroutineScope, ioContext: CoroutineContext, onFrameWritten: suspend (framesWritten: Int, writtenDuration: Duration) -> Unit) : SuspendClosable

A class for encoding GIF files. This encoder supports writing multiple frames in parallel. The dimensions of the created GIF are determined by the first frame written. Subsequent frames will have the same dimensions as the first frame, cropping or padding the frame to fit if necessary. The encoder must be closed after use to ensure all data is written correctly.

expect class ParallelGifEncoder constructor(sink: Sink, colorDifferenceTolerance: Double = 0.0, quantizedColorDifferenceTolerance: Double = -1.0, loopCount: Int = 0, maxColors: Int = GIF_MAX_COLORS, colorQuantizer: ColorQuantizer = ColorQuantizer.NEU_QUANT, colorSimilarityChecker: ColorSimilarityChecker = ColorSimilarityChecker.EUCLIDEAN_LUMINANCE_WEIGHTING, comment: String = "", transparentAlphaThreshold: Int = 20, alphaFill: Int = -1, cropTransparent: Boolean = true, minimumFrameDurationCentiseconds: Int = GIF_MINIMUM_FRAME_DURATION_CENTISECONDS, maxConcurrency: Int = 2, coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext), ioContext: CoroutineContext = EmptyCoroutineContext, onFrameWritten: suspend (framesWritten: Int, writtenDuration: Duration) -> Unit = { _, _ -> }) : SuspendClosable

A class for encoding GIF files. This encoder supports writing multiple frames in parallel. The dimensions of the created GIF are determined by the first frame written. Subsequent frames will have the same dimensions as the first frame, cropping or padding the frame to fit if necessary. The encoder must be closed after use to ensure all data is written correctly.

Link copied to clipboard
data class QuantizedImageData(val imageColorIndices: ByteArray, val width: Int, val height: Int, val x: Int, val y: Int, val colorTable: ByteArray, val transparentColorIndex: Int)

Represents quantized image data that is to be encoded into a GIF frame.

Link copied to clipboard
actual interface RandomAccessData : AutoCloseable

A source of data which supports random access reading.

expect interface RandomAccessData : AutoCloseable

A source of data which supports random access reading.

actual interface RandomAccessData : AutoCloseable

A source of data which supports random access reading.

actual interface RandomAccessData : AutoCloseable

A source of data which supports random access reading.

actual interface RandomAccessData : AutoCloseable

A source of data which supports random access reading.

actual interface RandomAccessData : AutoCloseable

A source of data which supports random access reading.

Link copied to clipboard
value class RGB(val value: Int)

Represents an ARGB color, with one byte per component.

Link copied to clipboard
fun interface SuspendClosable

A resource that can be closed or released asynchronously.

Properties

Link copied to clipboard

The pixel data of this Bitmap. Each element in the array represents a pixel in ARGB format, going row by row from top to bottom.

The pixel data of this BufferedImage. Each element in the array represents a pixel in ARGB format, going row by row from top to bottom.

Link copied to clipboard

Returns a Duration equal to this Int number of centiseconds.

Link copied to clipboard

The CoroutineScope in which the concurrent encoding operations will run. Used when creating a ParallelGifEncoder.

The CoroutineScope in which the concurrent encoding operations will run. Used when creating a ParallelGifEncoder.

The CoroutineScope in which the concurrent encoding operations will run. Used when creating a ParallelGifEncoder.

Link copied to clipboard
const val GIF_MAX_COLORS: Int = 256

The maximum number of colors allowed in a GIF frame.

Link copied to clipboard

The minimum duration of a GIF frame in centiseconds that is supported by most GIF viewers.

Link copied to clipboard

The CoroutineContext to use for writing to the sink. Used when creating a ParallelGifEncoder.

The CoroutineContext to use for writing to the sink. Used when creating a ParallelGifEncoder.

The CoroutineContext to use for writing to the sink. Used when creating a ParallelGifEncoder.

Link copied to clipboard

The maximum number of frames that can be processed concurrently at the same time. Used when creating a ParallelGifEncoder.

The maximum number of frames that can be processed concurrently at the same time. Used when creating a ParallelGifEncoder.

The maximum number of frames that can be processed concurrently at the same time. Used when creating a ParallelGifEncoder.

Functions

Link copied to clipboard
fun ERROR CLASS: Symbol not found for File.asRandomAccess(): RandomAccessData
fun ERROR CLASS: Symbol not found for JavaPath.asRandomAccess(): RandomAccessData

Creates a RandomAccessData instance that reads from a file.

Creates a RandomAccessData instance that reads from a byte array.

Creates a RandomAccessData instance that reads from a file.

fun ArrayBuffer.asRandomAccess(): RandomAccessData

Creates a RandomAccessData instance that reads from an ArrayBuffer.

Creates a RandomAccessData instance that reads from an Int8Array.

Link copied to clipboard

Creates a new GifEncoderBuilder for configuring and building a GifEncoder.

Link copied to clipboard
actual fun GifEncoderBuilder.buildParallel(onFrameWritten: suspend (framesWritten: Int, writtenDuration: Duration) -> Unit): ParallelGifEncoder

Builds a ParallelGifEncoder with the specified parameters.

actual fun GifEncoderBuilder.buildParallel(onFrameWritten: suspend (framesWritten: Int, writtenDuration: Duration) -> Unit): ParallelGifEncoder

Builds a ParallelGifEncoder with the specified parameters.

expect fun GifEncoderBuilder.buildParallel(onFrameWritten: suspend (framesWritten: Int, writtenDuration: Duration) -> Unit = { _, _ -> }): ParallelGifEncoder

Builds a ParallelGifEncoder with the specified parameters.

Link copied to clipboard
fun FrameInfo.copy(duration: Duration = this.duration, timestamp: Duration = this.timestamp): FrameInfo

Creates a copy of this FrameInfo with the specified properties.

fun ImageFrame.copy(argb: IntArray = this.argb, width: Int = this.width, height: Int = this.height, duration: Duration = this.duration, timestamp: Duration = this.timestamp, index: Int = this.index): ImageFrame

Creates a copy of this ImageFrame with the specified properties.

Link copied to clipboard
fun GifDecoder(path: Path, cacheFrameInterval: Int = DEFAULT_GIF_CACHE_FRAME_INTERVAL): GifDecoder

Constructs a GifDecoder, reading GIF data from a file.

fun GifDecoder(buffer: ArrayBuffer, cacheFrameInterval: Int = DEFAULT_GIF_CACHE_FRAME_INTERVAL): GifDecoder

Constructs a GifDecoder, reading GIF data from a ArrayBuffer.

fun GifDecoder(bytes: Int8Array, cacheFrameInterval: Int = DEFAULT_GIF_CACHE_FRAME_INTERVAL): GifDecoder

Constructs a GifDecoder, reading GIF data from an Int8Array.

Link copied to clipboard

Creates a RandomAccessData instance that reads from a file.

Creates a RandomAccessData instance that reads from a file.

Creates a RandomAccessData instance that reads from a file.

Creates a RandomAccessData instance that reads from a file.

Link copied to clipboard
fun quantizeGifImage(image: Image, maxColors: Int, transparentAlphaThreshold: Int, quantizer: ColorQuantizer, forceTransparency: Boolean): QuantizedImageData

Quantizes the given image to a maximum number of colors.

Link copied to clipboard

Creates a lazy sequence of ImageFrames from the GIF data in this Source. The sequence decodes the GIF frames on demand, minimizing memory usage. The returned sequence can only be iterated over once.

Link copied to clipboard
fun ByteArray.source(offset: Int = 0): Source

Creates a Source reading from this byte array.

Link copied to clipboard
inline suspend fun <T : SuspendClosable?, R> T.use(block: (T) -> R): R

Executes the given block function on this resource and then closes it down correctly whether an exception is thrown or not.

Link copied to clipboard
fun Sink.writeGifImage(imageData: QuantizedImageData, durationCentiseconds: Int, disposalMethod: DisposalMethod)

Encodes the given quantized image data to a GIF frame and writes it to the sink.