Socket
Book a DemoInstallSign in
Socket

awesome-image-utils

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome-image-utils

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

0.10.0
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

常用工具函数

  • 文件保存 file-saver
  • 图片处理:File转Blob、Blob转File、本地图片URL转base64

通用方法

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')
})

Keywords

image

FAQs

Package last updated on 12 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.