/** * Frame Manipulation Utilities * * Provides utilities for manipulating image frames before creating GIFs, * including GIF timing and sequence manipulation. */ import { ImageData } from './types.js'; import { GifResult } from './gif-result.js'; export interface CropOptions { x: number; y: number; width: number; height: number; } export interface ResizeOptions { width: number; height: number; /** Resize algorithm: 'nearest' or 'bilinear' */ algorithm?: 'nearest' | 'bilinear'; } export interface RotateOptions { /** Rotation angle in degrees (90, 180, 270) */ angle: 90 | 180 | 270; } export interface FlipOptions { /** Flip horizontally */ horizontal?: boolean; /** Flip vertically */ vertical?: boolean; } export interface ColorAdjustOptions { /** Brightness adjustment (-1 to 1) */ brightness?: number; /** Contrast adjustment (-1 to 1) */ contrast?: number; /** Saturation adjustment (-1 to 1) */ saturation?: number; /** Hue shift in degrees (-180 to 180) */ hue?: number; } /** * Crops an image to the specified rectangle */ export declare function cropImage(imageData: ImageData, options: CropOptions): ImageData; /** * Resizes an image using nearest neighbor or bilinear interpolation */ export declare function resizeImage(imageData: ImageData, options: ResizeOptions): ImageData; /** * Rotates an image by 90, 180, or 270 degrees */ export declare function rotateImage(imageData: ImageData, options: RotateOptions): ImageData; /** * Flips an image horizontally and/or vertically */ export declare function flipImage(imageData: ImageData, options: FlipOptions): ImageData; /** * Adjusts color properties of an image */ export declare function adjustColors(imageData: ImageData, options: ColorAdjustOptions): ImageData; /** * Applies a simple blur effect */ export declare function blurImage(imageData: ImageData, radius?: number): ImageData; export interface GifSpeedOptions { /** Speed multiplier (0.5 = half speed, 2.0 = double speed) */ speedMultiplier: number; /** Minimum delay in milliseconds (prevents too-fast animations) */ minDelay?: number; /** Maximum delay in milliseconds (prevents too-slow animations) */ maxDelay?: number; } export interface GifManipulationOptions { /** Whether to reverse the frame order */ reverse?: boolean; /** Speed adjustment options */ speed?: GifSpeedOptions; } /** * Reverses the frame order of an animated GIF * * Creates a new GIF with frames in reverse order, creating a "boomerang" * or reverse playback effect. * * @param gifData - Original GIF data as Uint8Array * @returns A new GIF with reversed frame order * * @example * ```typescript * const reversedGif = reverseGif(originalGifData); * ``` */ export declare function reverseGif(gifData: Uint8Array): GifResult; /** * Changes the playback speed of an animated GIF * * Adjusts frame delays to speed up or slow down animation playback. * Includes safety limits to prevent extremely fast or slow animations. * * @param gifData - Original GIF data as Uint8Array * @param options - Speed adjustment options * @returns A new GIF with adjusted playback speed * * @example * ```typescript * // Double the speed * const fastGif = changeGifSpeed(originalGifData, { speedMultiplier: 2.0 }); * * // Half speed with minimum delay * const slowGif = changeGifSpeed(originalGifData, { * speedMultiplier: 0.5, * minDelay: 50 * }); * ``` */ export declare function changeGifSpeed(gifData: Uint8Array, options: GifSpeedOptions): GifResult; /** * Applies multiple manipulations to a GIF (reverse, speed change, etc.) * * Combines multiple GIF manipulation operations into a single function * for convenience and better performance. * * @param gifData - Original GIF data as Uint8Array * @param options - Manipulation options * @returns A new GIF with applied manipulations * * @example * ```typescript * // Create a reversed, double-speed GIF * const manipulatedGif = manipulateGif(originalGifData, { * reverse: true, * speed: { speedMultiplier: 2.0 } * }); * * // Just slow down * const slowGif = manipulateGif(originalGifData, { * speed: { speedMultiplier: 0.5, minDelay: 100 } * }); * ``` */ export declare function manipulateGif(gifData: Uint8Array, options: GifManipulationOptions): GifResult;