npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

super-image-cropper

v1.0.18

Published

Crop GIF / PNG / JPG / JPEG images using Javascript.

Downloads

1,871

Readme

Super Image Cropper

Crop GIF / PNG / JPG / JPEG images using Javascript.

npm npm GitHub license

Features

  • Support for GIF cropping.
  • Support for collaboration with cropperjs.
  • Support for PNG / JPG / JPEG cropping.

Experience

Preview

GIF

Static Image

Getting started

Installation

npm i super-image-cropper -S

or

yarn add super-image-cropper -S

Usage

Recommend for use with cropperjs.

Properties

  • src: image url.
  • crossOrigin: set image crossOrigin strategy.
  • cropperInstance: cropperjs instance.
  • cropperJsOpts:
    • x: the offset left of the cropped area.
    • y: the offset top of the cropped area.
    • width: the width of the cropped area
    • height: the height of the cropped area.
    • rotate: the rotated degrees of the image.
    • scaleX: the scaling factor to apply on the abscissa of the image.
    • scaleY: the scaling factor to apply on the ordinate of the image.
    • background: GIF background color.
  • gifJsOptions: gif.js options.
  • outputType: Set output type.
    • base64: Output base64.
    • blob: Output blob object.
    • blobURL: Output blob url. (e.g: blob:http://localhost:3000/8a583ca5-e87c-4750-93b0-da05f69b702a)

Working with cropperjs

  <img id="cropperJsRoot" src="xxx.gif"></img>
import { SuperImageCropper } from 'super-image-cropper';
import Cropper from 'cropperjs';

const image = document.getElementById('image') as HTMLImageElement;
const cropperInstance = new Cropper(image, {
  aspectRatio: 16 / 9,
  autoCrop: false,
  autoCropArea: 1,
  minCropBoxHeight: 10,
  minCropBoxWidth: 10,
  viewMode: 1,
  initialAspectRatio: 1,
  responsive: false,
  guides: true
});

const imageCropper = new SuperImageCropper();

imageCropper.crop({
  cropperInstance: cropperInstance,
  src: 'xxx.gif',
  outputType: 'blobURL' // optional, default blob url
}).then(blobUrl => {
  const img = document.createElement('img');
  img.src = blobUrl;
  document.body.appendChild(img);
});

Use alone

If not used with cropperjs, the src parameter must be passed.

import { SuperImageCropper } from 'super-image-cropper';

const imageCropper = new SuperImageCropper();

imageCropper.crop({
  src: gifUrl,
  cropperJsOpts: {
    width: 400,
    height: 240,
    rotate: 45,
    y: 0,
    x: 0,
  }
}).then(blobUrl => {
  const img = document.createElement('img');
  img.src = blobUrl;
  document.body.appendChild(img);
});

Example

  • Used with react-cropper or cropperjs in react: React App.