1.0.1 • Published 1 year ago
imgcompress-hcy v1.0.1
imgcompress-hcy ⚡
介绍
一个图片压缩的方法(可以指点宽度和高度,尺寸)并且不会失真
使用
npm 引入
npm install imgcompress-hcy
导入
import compressImage from 'imgcompress-hcy';
props 参数说明
参数 | 类型 | 说明 | 必须 |
---|---|---|---|
width | number | 单位是px | true |
height | number | 单位是px | true |
targetSize | number | 单位是kb | true |
file | file | 图片文件 | true |
使用示例
<template>
<input type="file" @change="onFileChange">
</template>
<script setup>
import compressImage from 'imgcompress-hcy';
const onFileChange = async (e)=>{
let res = await compressImage(800,800,200,e.target.files[0])
console.log(res);
}
</script>