🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

smartcrop-wasm

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

smartcrop-wasm

WebAssembly implementation of smartcrop.js

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
7
-36.36%
Maintainers
1
Weekly downloads
 
Created
Source

smartcrop-wasm

npm version install size

WebAssembly implementation of smartcrop.js.

Install

# npm
$ npm install smartcrop-wasm

# or yarn
$ yarn add smartcrop-wasm

Usage

import * as smartcrop from 'smartcrop-wasm';

const image = await fetch(img.src)
  .then((res) => res.arrayBuffer())
  .then((res) => new Uint8Array(res));

const result = smartcrop.crop(image, 100, 100);
// => [ 0, 25, 200, 200 ]

API

crop(image, width, height)

Find the best crop for image.

args

image: Uint8Array

The image data converted Uint8Array.

width: number

Crop width.

height: number

Crop height.

return: [number, number, number, number]

Return [x, y, width, height] result.

Development

# build for wasm
$ wasm-pack build

# npm package files
$ tree pkg
pkg/
├── package.json
├── README.md
├── smartcrop_wasm_bg.d.ts
├── smartcrop_wasm_bg.js
├── smartcrop_wasm_bg.wasm
├── smartcrop_wasm.d.ts
└── smartcrop_wasm.js

FAQs

Package last updated on 29 Jul 2020

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