New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bee-crop

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bee-crop

image crop

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by400%
Maintainers
1
Weekly downloads
 
Created
Source

bee-crop

传统的图片裁剪是每裁剪一次,就需要存储对应的图片资源,当裁剪比较频繁时会造成大量的资源浪费。解决此问题,可以仅存储裁剪坐标数据,如此一来,无论源图片被裁剪多少次,图片资源永远唯一,避免了资源的浪费。

一种方法是在服务器端实现,坐标信息拼接进图片的url里面,后端服务返回所需的图片。

另一种方法是在客户端(web)实现,利用canvas生成裁剪图片

引入

  • npm
npm install bee-crop
# or
cnpm install bee-crop
# or
yarn add bee-crop
import 'bee-crop'
  • script
<script src="https://unpkg.com/bee-crop"></script>

参数

属性类型解释
srcstring源图片链接
xnumber裁剪相对于源图片x轴距离
ynumber裁剪相对于源图片y轴距离
widthnumber截取宽度
heightnumber截取高度

使用

BeeCrop({
  "src": "https://fengyuanchen.github.io/cropperjs/images/picture.jpg",
  "x": 128,
  "y": 72,
  "width": 1024,
  "height": 576
}).then((base64) => {
  document.querySelector('img').src = base64
})

案例

example

更多

需要添加功能或者存在 bug 请提交 issues,在空余时间会尽快处理。

Keywords

FAQs

Package last updated on 14 Oct 2017

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc