beatprints.js
Version:
A Node.js version of the original Python BeatPrints project (https://github.com/TrueMyst/BeatPrints/) by TrueMyst. Create eye-catching, Pinterest-style music posters effortlessly. BeatPrints integrates with Spotify and LRClib API to help you design custom
49 lines (48 loc) • 2.56 kB
TypeScript
import { ThemesSelector } from './constants.js';
import type { RGB } from './write.js';
import type { CanvasRenderingContext2D } from '@napi-rs/canvas';
export declare function getPalette(image: Buffer): Promise<RGB[]>;
/**
* Draws a color palette on the given image.
* @param {CanvasRenderingContext2D} ctx The canvas rendering context.
* @param {Buffer} image The image from which the color palette will be drawn.
* @param {boolean} accent If true, an accent color is added at the bottom. Defaults to false.
*/
export declare function drawPalette(ctx: CanvasRenderingContext2D, image: Buffer, accent?: boolean): Promise<void>;
/**
* Crops the image buffer to a square aspect ratio.
* @param {Buffer} buffer The image from which the crop will be applied.
* @returns {Promise<Buffer>} A new buffer containing the cropped square image.
*/
export declare function crop(buffer: Buffer): Promise<Buffer>;
/**
* Adjusts the brightness and contrast of an image buffer.
*
* - Brightness is reduced by 10% (i.e., 90% of original)
* - Contrast is reduced by 20% (i.e., 80% of original)
*
* @param {Buffer} image Buffer or Sharp instance of the image
* @returns {Promise<Buffer>} The processed image buffer
*/
export declare function magicify(image: Buffer): Promise<Buffer>;
/**
* Generates a Spotify scannable code for a track or album.
* @param {string} id The Spotify track or album ID.
* @param {ThemesSelector.Options} theme The theme for the scannable code. Defaults to 'Light'.
* @param {'track' | 'album'} item Specifies the type of the scannable code. Defaults to 'track'.
* @returns {Promise<Buffer>} A buffer containing the resized scannable code image.
*/
export declare function scannable(id: string, theme?: ThemesSelector.Options, item?: 'track' | 'album'): Promise<Buffer>;
/**
* Fetches and processes an image from a URL or Buffer image.
* @param {string} url The URL of the image.
* @param {string | Buffer} source The local path of the image. If provided, the image will be loaded from this path; otherwise, it will be fetched from the URL.
* @returns {Promise<Buffer>} A buffer containing the processed image.
*/
export declare function cover(url: string, source?: string | Buffer): Promise<Buffer>;
/**
* Returns theme-related properties based on the selected theme.
* @param {ThemesSelector.Options} theme The selected theme. Defaults to 'Light'.
* @returns {[RGB, string]} A tuple containing the thee color and the template path.
*/
export declare function getTheme(theme?: ThemesSelector.Options): [RGB, string];