一款简洁的 image-crop.js图片裁剪工具

用起来还挺方便的

ImageCrop 图片裁剪: javascript原生图片裁剪


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./ImageCrop.js"></script>
    <link href="./ImageCrop.css" rel="stylesheet">
    <title>ImageCrop 2.0</title>
</head>

<body>
    <input id="file" type="file">
    <img id="show">

    <div id="imageCrop"></div>
</body>
<script>
    let imageCrop = new ImageCrop({
        el: "#file",
        watch: true,
        cropWidth: 600,
        cropHeight: 300,
        canvasWidth: 1300,
        canvasHeight: 500,
    });
    
    imageCrop.onChange = (base64, file) => {
        document.querySelector("#show").src = base64;
    }
</script>

</html>
属性类型默认值说明
elelnullinput[type="file"]
watchbooleanfalse实时回调 onChange方法
cropWidthnumber600裁剪框 宽度
cropHeightnumber300裁剪框 高度
canvasWidthnumber900画布 宽度
canvasHeightnumber450画布 高度
onChangefnnull裁剪按钮回调

 

ImageCrop: ImageCrop,图片裁剪,图片处理工具,支持自定义裁剪宽度,支持放大缩小移动等,支持Vue 等其他框架;性能优越原生JavasScript写法兼容各类框架。 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值