nicecode-v2/packages/utils/lib/file/index.d.ts
2023-12-21 14:38:13 +08:00

55 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
*
* @param url 需要转为图片的链接
* @returns 图片的 dom
*/
export declare const urlToImg: (url: string) => Promise<HTMLImageElement>;
export declare const base64DecodeImageKey: (base64ImgKey: string) => string;
/**
* 通过url获取图片的base64字符串
* @param src 图片链接
* @param outputFormat 图片格式
* @returns base64 @string
*/
export declare const getBase64ByUrl: (src: string | URL, outputFormat?: string) => Promise<unknown>;
/**
* 把文件转base64
* @param file @file 文件
* @returns @string
*/
export declare const fileToBase64: (file: any) => Promise<string>;
/**
*
* @param image @file 图片文件
* @param width @number 宽度
* @param height @number 高度
* @returns @string base64
*/
export declare const getBase64Image: (image: any, width?: any, height?: any) => string;
/**
* 通过图片获取base64
* @param src 图片地址
* @returns @string
*/
export declare const getBase64ByImage: (src: string) => Promise<unknown>;
/**
* url转base64
* @param {String} url - url地址
*/
export declare const urlToBase64V2: (url: string) => Promise<unknown>;
/**
* base64转Blob
* @param {String} base64 - base64
*/
export declare function base64toBlob(base64: string): Blob | undefined;
/**
* 图片集打包压缩下载
* 1. url -> base64 -> blob
* 2. 将blob加入jsZip文件夹内用file-saver保存
* @param {Array<{url:string,name:string}>} imgDataList
* @param {string} zipName
*/
export declare const downloadPackageImages: (imgDataList: string | any[], zipName: string) => Promise<void>;
export declare function getFileSize(size: number): string;
export declare const dataURLToBlob: (dataurl: string) => Blob;