UNPKG

@crowdin/crowdin-apps-functions

Version:

Utility library to easily and quickly develop Crowdin App

38 lines (37 loc) 1.13 kB
/// <reference types="node" /> /** * Provides tools for adding annotations to images using the Jimp library. * Capable of resizing images, drawing rectangles, and placing text labels with backgrounds. */ declare class ImageAnnotator { private imageBuffer; private static readonly FONT_SIZE; private static readonly SHORT_SIDE_MAX_SIZE; private static readonly LONG_SIDE_MAX_SIZE; private static readonly AVERAGE_CHAR_WIDTH; private static readonly PADDING_PIXELS; private image; private originalWidth; private originalHeight; private imageWidth; private imageHeight; private borderColor; private backgroundColor; constructor(imageBuffer: Buffer); private initialize; annotate(tracks: Array<{ x: number; y: number; w: number; h: number; text: string; }>): Promise<Buffer>; private calculateNewDimensions; private adjustTrackCoordinates; private drawRectangle; private drawTextBackground; private createText; private fitTextWithinBounds; private getTextWidth; } export default ImageAnnotator;