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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lizychy0329/we-cropper

v1.2.4

Published

A wechat style image cropper wrapper with vue-advanced-cropper

Readme

Features

  • Easy to Use: Simple API with just one core useCropper hook
  • 🦾 Strongly Typed: Full TypeScript support with comprehensive type definitions
  • 🌍 i18n Support: Built-in internationalization with 9 languages and custom locale support
  • 🚀 Fixed Cropping Box: Consistent cropping area with configurable aspect ratio
  • 🎯 Auto Zoom: Automatically zooms in on the crop area for precise editing
  • ❄️ ESM / UMD Support: Works seamlessly in both modern and legacy environments

Requirements

{
  "peerDependencies": {
    "vue": "^3.0.0"
  }
}

Installation

pnpm add @lizychy0329/we-cropper

Quick Start

import { fileToBase64, useCropper } from '@lizychy0329/we-cropper'

// Initialize cropper with basic configuration
const { showCropper, onCrop } = useCropper({
  el: '#cropper-container', // defaults to document.body
  aspectRatio: 1 / 1,
  locale: 'en' // built-in English support
})

const { onChange } = useFileDialog({
// Handle file selection with @vueuse/useFileDialog
const { onChange } = useFileDialog({
  multiple: false,
  accept: 'image/*'
})

const croppedImage = ref('')
onChange(async (files) => {
  const base64String = await fileToBase64(files[0])
  showCropper(base64String)
})

// Handle cropped result
onCrop((base64String) => {
  croppedImage.value = base64String
  // Upload to your server or further processing
})

Internationalization (i18n)

Built-in Languages

we-cropper supports 9 languages out of the box:

| Code | Language | File | |------|----------|------| | en | English | en.ts | | zh-cn | Chinese (Simplified) | zh-cn.ts | | zh-tw | Chinese (Traditional) | zh-tw.ts | | ja | Japanese | ja.ts | | ko | Korean | ko.ts | | fr | French | fr.ts | | de | German | de.ts | | es | Spanish | es.ts | | ru | Russian | ru.ts |

Basic Usage

import { useCropper } from '@lizychy0329/we-cropper'

// Use built-in language
const { showCropper } = useCropper({
  locale: 'zh-CN' // Chinese interface
})

showCropper('data:image/png;base64,...')

Dynamic Language Switching

import { useCropper } from '@lizychy0329/we-cropper'

const { showCropper, setLocale, currentLocale } = useCropper({
  locale: 'en'
})

// Switch language dynamically
function switchToChinese() {
  setLocale('zh-CN')
  console.log(currentLocale.value) // 'zh-cn'
}

// Show cropper with current language
showCropper('data:image/png;base64,...')

Custom Localization

import { useCropper } from '@lizychy0329/we-cropper'

const customLocale = {
  'en': {
    loading: 'Processing image...',
    reset: 'Reset Image',
    confirm: 'Confirm Crop',
    cancel: 'Cancel Operation',
    rotate: 'Rotate Image',
    error: {
      loadImage: 'Failed to load image',
      cropImage: 'Failed to crop image'
    },
    tooltip: {
      rotate: 'Click to rotate image',
      reset: 'Reset to original state'
    }
  }
}

const { showCropper } = useCropper({
  locale: 'en',
  customLocale
})

API Reference

useCropper

function useCropper(options?: UseCropperOptions): {
  onCrop: EventHookOn<string>     // Crop completion event
  showCropper: (src: string) => void  // Display cropper
  setLocale: (locale: LocaleCode) => void  // Set language
  currentLocale: ComputedRef<LocaleCode>  // Current language
}

UseCropperOptions

interface UseCropperOptions {
  locale?: LocaleCode                    // Language setting
  customLocale?: CustomLocale           // Custom language pack
  aspectRatio?: number                   // Crop ratio (default: 1)
  el?: HTMLElement | string             // Mount element (default: document.body)
  // Legacy text props (deprecated but still supported)
  loadingText?: string
  resetText?: string
  confirmText?: string
  cancelText?: string
}

Utility Functions

// Convert base64 to Blob
export function base64ToBlob(base64String: string): Promise<Blob>

// Convert File to base64
export function fileToBase64(file: File): Promise<string>

// Convert URL to base64
export function urlToBase64(url: string, mineType?: string): Promise<string>

Screenshot

we-cropper interface

Development

# Start development server
pnpm dev

# Build library
pnpm build:lib

# Build documentation
pnpm build:docs

License

MIT