img-utils-browser
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

img-utils

一些处理图片的实用方法

mergeImgs

合并图片

import { mergeImgs } from 'img-utils-browser';
mergeImgs(
  [
    { url: 'url1', x: 0, y: 8, w: 10, h: 10 },
    { url: 'url2', x: 8, y: 0, w: 20, h: 20 },
  ],
  40,
  20,
).then((imgStr) => {
  const img = new Image();
  img.setAttribute('style', 'border: 1px solid red; margin: 5px;');
  img.src = imgStr;
  document.body.append(img);
});

裁剪图片

import { cropImg } from 'img-utils-browser';
cropImg('url', 25, 0, 25, 22).then((base64) => {
  const img = new Image();
  img.src = base64;
  document.body.append(img);
});

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i img-utils-browser

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    7.03 kB

    Total Files

    7

    Last publish

    Collaborators

    • qjsama