Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including image-edit with all npm packages installed. Try it out:

var imageEdit = require("image-edit")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

image-edit v0.2.21

easy edit image client library

image-edit

eazy image compress client web library.

Demo

Get Started

yarn add image-edit

Usage

<input type="file" id="file" accept="image/*" />
import edit from 'image-edit'

document.getElementById('file').addEventListener('change', async (e) => {
  const file = e.target.files[0];

  if (!file) {
    return;
  }
  try {
    const imageData = await edit(file, { quality: 0.7, mimeType: 'image/webp'})
    const fromData = new FormData()
    formData.append('file' imageData, file.name)
    await fetch('/path/to/upload', {
      method: 'post',
      body: formData
    })
  } catch (err) {
    console.log(err)
  }
})

Options

  • fillStyle
  • rotate
  • scaleX
  • scaleY
  • width
  • height
  • maxWidth
  • maxHeight
  • minWidth
  • minHeight
  • quality
  • mimeType

Licence

MIT

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free