当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 0

None / cutphoto
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

cutphoto

cutphoto是一个简单易用的切图工具,没有条条框框,全部自定义

目前项目依赖 zrender, hammer, lrz

DEMO

DEMO

文档详细说明

git@osc 的pages有点问题,可以通过 npm run docs:view 查看文档 文档

使用

// 使用
const cutphoto = new Cutphoto({
  image: { img: img.src },
  container: document.querySelector('#cutphoto'),
  mask: {
    img:this.$refs.backbg.src,
    size: [230, 160],
    opacity:0.98
  },
  output: {
      size: [230, 160],
  },
})
// 调整好图片位置大小后调用done即可获取新图片的base64
const base64=cutphoto.done().base64

// 可以通过调用preview方法进行预览,size设置越大越影响性能,预览不影响输出大小,尽量小
cutphoto.preview([125,80],data => {
    const src = data.base64
    // ...do something
})

参数

// 接收参数如下
interface Option {
  /**
   * @description: 容器
   */  
  container?: HTMLElement
  /**
   * @description: 待处理原始图片
   */  
  image: {
    /**
     * @description: 图片对象
     */  
    img: Img
    /**
     * @description: 最大缩放
     */  
    maxZoom?: number
    /**
     * @description: 最小缩放
     */   
    minZoom?: number
  }
  /**
   * @description: 初始化时进行压缩,压缩后的宽高与质量
   */   
  lrz?: {
    /**
     * @description: 图片大小
     */ 
    size?: Size
    /**
     * @description: 图片质量
     */  
    quality?: number
  }
  /**
   * @description: 遮罩背景图
   */ 
  mask?: {
    /**
   * @description: 遮罩层图片透明度
   */  
    opacity?: number
    /**
     * @description: 遮罩层图片
     */ 
    img?: string
    /**
     * @description: 遮罩层大小
     */ 
    size?: Size
    /**
     * @description: 遮罩层位置
     */ 
    position?: Point
    // // 是否支持调节
    // resize?: boolean
    // // 固定比例
    // ratio?: boolean
  }
  /**
   * @description: 输出参数
   */ 
  output?: {
    /**
     * @description: 输出图片size
     */  
    size?: Size
    /**
     * @description: 输出图片质量
     */   
    quality?: number
    /**
     * @description: 输出类型
     */    
    type?: string
  }
  /**
   * @description: 预览设置
   */ 
  preview?: {
    /**
     * @description: 预览大小
     */ 
    size?: Size
    /**
     * @description: 预览回调函数
     */ 
    callback?: (output: Output) => any
  }
}
MIT License Copyright (c) 2019 Arcoon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

图片裁剪 展开 收起
TypeScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/none/cutphoto.git
git@gitee.com:none/cutphoto.git
none
cutphoto
cutphoto
master

搜索帮助