UNPKG

@picoxr/web-cli-core

Version:

Core Library to generate, build and sign TWA projects

52 lines (51 loc) 1.81 kB
/// <reference types="node" /> import * as Jimp from 'jimp'; import Color = require('color'); import { WebManifestIcon } from './types/WebManifest'; export interface IconDefinition { dest: string; size: number; } export interface Icon { url: string; data: Jimp; } export declare class ImageHelper { private saveIcon; private generateCompositeImage; private getRoundedImage; private getMainColor; private updateBoundariesAndDetectInThreshold; private middle; private detectRoundPure; private cropRoundPureImage; private originalCropRoundPureImage; /** * Generate a file for the given icon inside targetDir. * * @param {Object} icon Object containing the original URL and the icon image data. * @param {string} targetDir Path to the directory the image will be saved in. * @param {Object} iconDef Icon definitions specifying the size the icon should be exported as. */ generateIcon(icon: Icon, targetDir: string, iconDef: IconDefinition, backgroundColor?: Color, options?: { originalIcon: WebManifestIcon | null; transform: boolean; }): Promise<void>; /** * Set the color of a monochrome icon to be the theme color. * * @param {Object} icon Original monochrome icon to use. * @param {Color} themeColor Color to use for the icon. * @returns New image data. */ monochromeFilter(icon: Icon, themeColor: Color): Promise<Icon>; /** * Fetches an Icon. * * @param {string} iconUrl the URL to fetch the icon from. * @returns an Object containing the original URL and the icon image data. */ fetchIcon(iconUrl: string): Promise<Icon>; webp2PngBuffer(buffer: Buffer): Promise<Buffer>; fetchLocalIcon(localPath: any): Promise<Icon>; }