Giter VIP home page Giter VIP logo

img-splitter's Introduction

img-splitter

图片拆分库, 支持将 一张图片,规则拆分成多张图片

安装

npm i img-splitter

使用

import imgSplitter from 'img-splitter'

imgSplitter(
  'img url',
  {
    width: 50, // 每个拆分的小方块宽度
    height: 50, // 每个拆分的小方块高度
    chunk: 3, // 总共拆成多少张图
  }
)

尝试

codesanbox

原理

使用 OffscrenCanvas, 在 webworker 线程中去做图片的裁剪,提取等处理, 并生成多张图片。

优势:图片的操作,不会阻塞js线程的执行,也就是在js可以专心为为用户交互进行反馈,而不回会导致页面的卡死,卡顿等效果

缺点:webworker 兼容性问题

img-splitter's People

Contributors

croatialu avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.