Socket
Book a DemoInstallSign in
Socket

super-image-cropper

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

super-image-cropper

A powerful JavaScript image cropping library that supports GIF animations, PNG, JPG and other formats with CropperJS integration. Perfect for web developers who need to crop animated GIFs while preserving animation quality.

latest
Source
npmnpm
Version
1.0.27
Version published
Weekly downloads
338
112.58%
Maintainers
1
Weekly downloads
 
Created
Source

🖼️ Super Image Cropper

A powerful JavaScript image cropping library that supports GIF animations, PNG, JPG and other image formats.

npm version npm downloads GitHub license GitHub stars GitHub issues TypeScript

🌟 Live Demo | 📖 Documentation | 🇨🇳 中文文档

✨ Features

  • 🎬 GIF Animation Support - Crop animated GIFs while preserving animation
  • 🖼️ Multiple Formats - Support for PNG, JPG, JPEG, and GIF formats
  • 🔧 CropperJS Integration - Seamless integration with popular CropperJS library
  • 🎨 Flexible Output - Multiple output formats: Base64, Blob, or Blob URL
  • High Performance - Optimized for handling large images and animations
  • 🎯 Precise Control - Fine-grained control over cropping parameters
  • 📱 Cross-Platform - Works in all modern browsers
  • 🔄 Transform Support - Rotation and scaling transformations

🎯 Live Demo

Preview

GIF Animation Cropping

GIF Cropping Preview

Static Image Cropping

Static Image Cropping Preview

🚀 Quick Start

Installation

npm install super-image-cropper
yarn add super-image-cropper
pnpm add super-image-cropper

Basic Usage

<img id="image" src="your-image.gif" alt="Image to crop">
import { SuperImageCropper } from 'super-image-cropper';
import Cropper from 'cropperjs';

// Initialize 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
});

// Create cropper instance
const imageCropper = new SuperImageCropper();

// Crop the image
imageCropper.crop({
  cropperInstance: cropperInstance,
  src: 'your-image.gif',
  outputType: 'blobURL' // optional, default is blobURL
}).then(blobUrl => {
  const img = document.createElement('img');
  img.src = blobUrl;
  document.body.appendChild(img);
});

Standalone Usage

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

const imageCropper = new SuperImageCropper();

imageCropper.crop({
  src: 'your-image.gif',
  cropperJsOpts: {
    width: 400,
    height: 240,
    rotate: 45,
    x: 0,
    y: 0,
    scaleX: 1,
    scaleY: 1
  },
  outputType: 'base64'
}).then(result => {
  console.log('Cropped image:', result);
});

📖 API Reference

SuperImageCropper

Methods

crop(options: CropOptions): Promise<string | Blob>

Crops an image based on the provided options.

CropOptions

PropertyTypeRequiredDescription
srcstringYesImage URL or path
crossOriginstringNoCORS strategy for image loading
cropperInstanceCropperNoCropperJS instance (when used with CropperJS)
cropperJsOptsCropperJsOptionsNoManual cropping parameters
gifJsOptionsobjectNogif.js configuration
outputType'base64' | 'blob' | 'blobURL'NoOutput format (default: 'blobURL')

CropperJsOptions

PropertyTypeDescription
xnumberLeft offset of the cropped area
ynumberTop offset of the cropped area
widthnumberWidth of the cropped area
heightnumberHeight of the cropped area
rotatenumberRotation angle in degrees
scaleXnumberHorizontal scaling factor
scaleYnumberVertical scaling factor
backgroundstringBackground color for GIF (optional)

Output Types

  • base64 - Returns a base64 encoded string
  • blob - Returns a Blob object
  • blobURL - Returns a blob URL (e.g., blob:http://localhost:3000/8a583ca5...)

🔧 Examples

React Integration

Check out our React example for a complete implementation with React and CropperJS.

Advanced Usage

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

const cropper = new SuperImageCropper();

// Crop with custom GIF options
await cropper.crop({
  src: 'animated.gif',
  cropperJsOpts: {
    x: 100,
    y: 100,
    width: 300,
    height: 200,
    rotate: 90,
    background: '#ffffff'
  },
  gifJsOptions: {
    quality: 10,
    workers: 2,
    workerScript: 'gif.worker.js'
  },
  outputType: 'blob'
});

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/STDSuperman/super-image-cropper.git

# Install dependencies
pnpm install

# Build the project
pnpm build

Project Structure

super-image-cropper/
├── packages/
│   ├── super-image-cropper/    # Main library
│   └── gif-worker-js/          # GIF processing worker
├── example/                    # Example applications
├── docs/                       # Documentation
└── scripts/                    # Build and release scripts

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support

Made with ❤️ by STDSuperman

Keywords

image

FAQs

Package last updated on 23 Sep 2025

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