1.0.4 • Published 10 months ago

webp-converter-browser v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Demo

Introduce

Convert your image in browser side(frontend side).

Install

# npm
npm install webp-converter-browser

# yarn
yarn add webp-converter-browser

# pnpm
pnpm add webp-converter-browser

# bun
bun add webp-converter-browser

Usage

import { srcToWebP, blobToWebP, arrayBufferToWebP } from 'webp-converter-browser'

// ...

// When it cause CORS, you may failed to use `srcToWebP`
const webpBlob = await srcToWebP(pngSrc, { /** options */ })
// or
const webpBlob = await blobToWebP(pngBlob, { /** options */ })
// or
const webpBlob = await arrayBufferToWebP(jpgArrayBuffer, { /** options */ })

Vanilla

<script src="https://cdn.jsdelivr.net/npm/webp-converter-browser@latest/dist/index.min.js"></script>

<script>
  // ...

  // When it cause CORS, you may failed to use `srcToWebP`
  const webpBlob = await webpConverterBrowser.srcToWebP(pngSrc, { /** options */ })
  // or
  const webpBlob = await webpConverterBrowser.blobToWebP(pngBlob, { /** options */ })
  // or
  const webpBlob = await webpConverterBrowser.arrayBufferToWebP(jpgArrayBuffer, { /** options */ })
</script>

Options

NameDescriptionDefault
qualityimage quality0.75
widthimage widthGiven image width
heightimage heightGiven image height
1.0.4

10 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago