New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@saschazar/wasm-avif

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saschazar/wasm-avif

Encodes and decodes AVIF images using WebAssembly

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
decreased by-69.23%
Maintainers
1
Weekly downloads
 
Created
Source

npm

📦 WebAssembly AVIF decoder

A dependency-free AVIF decoder written in WebAssembly

It decodes AVIF-encoded image data in a Uint8Array containing raw RGB pixels.

Installation

yarn add @saschazar/wasm-avif

or

npm install --save @saschazar/wasm-avif

Usage

It supports usage in the browser, in a Web Worker and of course Node.js.

// Node.js
import wasm_avif from '@saschazar/wasm-avif';

// Web Worker - see: https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts
importScripts('wasm_avif.js');

// -------- Browser/Web Worker/Node.js code below --------

// Load encoded AVIF image data in Uint8Array
const array = new Uint8Array(['some', 'encoded', 'AVIF', 'image', 'data']);
let result;

// Initialize the WebAssembly Module
const avifModule = wasm_avif({
  onRuntimeInitialized() {
    result = avifModule.decode(array, array.length); // decode image data and return a new Uint8Array
    avifModule.free(); // clean up memory after encoding is done
  },
});

Example

A working example is available on RunKit.

Status

The main backbone of the project is the libavif library.

Currently only AVIF decoding using dav1d is enabled. Furthermore, only 8-bit images are getting decoded reliably.

Help needed

Concerning the encoding functionality, a few trials have been made towards using the libaom and rav1e encoder, but none of them succeeded yet.

The latest progress is visible as commented-out code in the build.sh and main.cpp.

Credits

This module uses the AOMediaCodec/libavif's source code and most of the code is written according to the examples provided in that repository.

License

Licensed under the MIT license.

Copyright ©️ 2020 Sascha Zarhuber

Keywords

FAQs

Package last updated on 20 Jul 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc