t-comm
Version: 
专业、稳定、纯粹的工具库
70 lines (69 loc) • 1.77 kB
TypeScript
/**
 * node环境下,保存base64图片到文件
 * @param {object} config 输入配置
 * @param {string} config.imgUrl base64图片Url
 * @param {string} config.savePath 保存路径,最好是绝对路径
 * @returns {Promise<string>} 去掉前缀的base64图片地址
 *
 * @example
 *
 * saveBase64ImgToFile({
 *   imgUrl: 'xx',
 *   savePath: '/test.png'
 * }).then((base64Data) => {
 *   console.log(base64Data)
 * })
 *
 */
export declare function saveBase64ImgToFile({ imgUrl, savePath }: {
    imgUrl: string;
    savePath: string;
}): Promise<string>;
/**
 * node环境下,本地图片转为base64
 * @param {string} savePath 本地图片保存路径
 * @returns {string} base64图片地址
 *
 * @example
 *
 * const base64str = turnLocalImg2Base64('/temp.png')
 *
 */
export declare function turnLocalImg2Base64(imgPath: string): string;
/**
 * node环境下,保存网络图片到本地
 * @param {object} config 输入配置
 * @param {string} config.imgUrl 网络图片地址
 * @param {string} config.savePath 本地图片保存路径,建议绝对路径
 * @returns {Promise<object>} 请求Promise
 *
 * @example
 *
 * saveRemoteImgToLocal({
 *   imgUrl: 'xx',
 *   savePath: './test.png'
 * }).then(() => {
 *
 * })
 */
export declare function saveRemoteImgToLocal({ imgUrl, savePath }: {
    imgUrl: string;
    savePath: string;
}): Promise<object>;
/**
 * 获取图片md5
 * @param {object} options 配置信息
 * @param {string} options.savePath 本地图片地址,建议绝对路径
 * @returns {Promise<string>} 图片md5值
 *
 * @example
 * getImgMd5({
 *  savePath: '/test.png'
 * }).then(md5 => {
 *   console.log(md5)
 * })
 * ```
 */
export declare function getImgMd5({ savePath }: {
    savePath: string;
}): Promise<string>;