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

node-webpmux

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-webpmux

A pure Javascript/WebAssembly re-implementation of webpmux

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is node-webpmux?

The node-webpmux package is a Node.js library for working with WebP images, particularly for handling WebP container format features such as metadata and animated WebP images.

What are node-webpmux's main functionalities?

Extracting Metadata

This feature allows you to extract metadata from a WebP image. The code sample reads a WebP file, loads it into a webpmux.Image object, and then retrieves the metadata.

const webpmux = require('node-webpmux');
const fs = require('fs');

async function extractMetadata(filePath) {
  const buffer = fs.readFileSync(filePath);
  const image = new webpmux.Image(buffer);
  await image.load();
  const metadata = image.getMetadata();
  console.log(metadata);
}

extractMetadata('path/to/your/image.webp');

Adding Metadata

This feature allows you to add metadata to a WebP image. The code sample reads a WebP file, loads it into a webpmux.Image object, sets new metadata, and then saves the modified image.

const webpmux = require('node-webpmux');
const fs = require('fs');

async function addMetadata(filePath, metadata) {
  const buffer = fs.readFileSync(filePath);
  const image = new webpmux.Image(buffer);
  await image.load();
  image.setMetadata(metadata);
  const newBuffer = await image.save();
  fs.writeFileSync('path/to/your/new_image.webp', newBuffer);
}

addMetadata('path/to/your/image.webp', { 'Title': 'Sample Image' });

Creating Animated WebP

This feature allows you to create an animated WebP image from multiple WebP frames. The code sample reads multiple WebP files, adds them as frames to an animation, and then saves the animated WebP image.

const webpmux = require('node-webpmux');
const fs = require('fs');

async function createAnimatedWebP(frames, outputFilePath) {
  const animation = new webpmux.Animation();
  for (const frame of frames) {
    const buffer = fs.readFileSync(frame.filePath);
    const image = new webpmux.Image(buffer);
    await image.load();
    animation.addFrame(image, frame.duration);
  }
  const newBuffer = await animation.save();
  fs.writeFileSync(outputFilePath, newBuffer);
}

const frames = [
  { filePath: 'frame1.webp', duration: 100 },
  { filePath: 'frame2.webp', duration: 100 }
];
createAnimatedWebP(frames, 'path/to/your/animated_image.webp');

Other packages similar to node-webpmux

FAQs

Package last updated on 27 Nov 2023

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