Skip to content

自用,一个用于解决各种图像处理问题的 TypeScript 库

License

Notifications You must be signed in to change notification settings

eachann1024/MDImage

Repository files navigation

常用工具函数

通用方法

fileToBlob:将 File 对象转换为 Blob URL

const blobUrl = fileToBlob(file)
// blobUrl 可以直接用于 img 标签的 src 属性

blobToFile:将 Blob 对象转换回 File 对象

const file = blobToFile(blob, 'image.png', 'image/png')

toBase64:将本地图片 URL 转换为 base64 编码

const base64 = await toBase64('/path/to/image.jpg')

UNIAPP 专用方法

UNI_toBase64:将本地图片 URL 转换为 base64 编码 (UNIAPP环境)

// 示例用法
const base64Image = ref('')
onLoad(async () => {
  base64Image.value = await UNI_toBase64('/static/images/logo.png')
})

About

自用,一个用于解决各种图像处理问题的 TypeScript 库

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published