You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

node-webpmux

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-webpmux - npm Package Compare versions

Comparing version
1.1.4
to
1.1.5
+1
-1
package.json
{
"name": "node-webpmux",
"version": "1.1.4",
"version": "1.1.5",
"description": "A pure Javascript re-implementation of webpmux",

@@ -5,0 +5,0 @@ "main": "webp.mjs",

+3
-1

@@ -83,3 +83,5 @@ A mostly-complete pure Javascript re-implementation of webpmux.

A convenience function to remux this image preserving settings. See the static .muxAnim function below for more information
Passing `true` for `exif`, `iccp`, or `xmp` will preserve whichever, if any, of those chunks exist in the original.
The `width`, `height`, `bgColor`, `loops`, `exif`, `iccp`, and `xmp` options default to the settings of this image.
Passing `false` to `exif`, `iccp`, or `xmp` will disable saving those
Should pass `0` to both `width` and `height` if any frame sizes were changed

@@ -86,0 +88,0 @@ async .save(path = this.path)

+23
-19

@@ -134,3 +134,3 @@ // https://developers.google.com/speed/webp/docs/riff_container

if (frame != -1) { start = end = frame; }
for (let i = start; i <= end; i++) {
for (let i = start; i < end; i++) {
await this.#demuxFrame((`${path}/${prefix}_${i}.webp`).replace(/#FNAME#/g, basename(this.path, '.webp')), this.anim.frames[i]);

@@ -142,3 +142,3 @@ }

if ((frame < 0) || (frame >= this.frameCount)) { throw new Error(`Frame index ${frame} out of bounds (0<=index<${this.frameCount})`); }
let r = new Image();
let r = new Image(), fr = this.anim.frames[frame];
await r.load(path);

@@ -154,9 +154,9 @@ switch (r.type) {

}
switch (this.anim.frames[frame].type) {
switch (fr.type) {
case constants.TYPE_LOSSY:
if (this.anim.frames[frame].vp8.alpha) { delete this.anim.frames[frame].alph; }
delete this.anim.frames[frame].vp8;
if (fr.vp8.alpha) { delete fr.alph; }
delete fr.vp8;
break;
case constants.TYPE_LOSSLESS:
delete this.anim.frames[frame].vp8l;
delete fr.vp8l;
break;

@@ -167,18 +167,21 @@ default: throw new Error('Unknown frame type');

case constants.TYPE_LOSSY:
this.anim.frames[frame].vp8 = r.data.vp8;
fr.vp8 = r.data.vp8;
fr.type = constants.TYPE_LOSSY;
break;
case constants.TYPE_LOSSLESS:
this.anim.frames[frame].vp8l = r.data.vp8l;
fr.vp8l = r.data.vp8l;
fr.type = constants.TYPE_LOSSLESS;
break;
case constants.TYPE_EXTENDED:
if (r.data.vp8) {
this.anim.frames[frame].vp8 = r.data.vp8;
if (r.data.vp8.alpha) { this.anim.frames[frame].alph = r.data.alph; }
} else if (r.data.vp8l) { this.anim.frames[frame].vp8l = r.data.vp8l; }
fr.vp8 = r.data.vp8;
if (r.data.vp8.alpha) { fr.alph = r.data.alph; }
fr.type = constants.TYPE_LOSSY;
} else if (r.data.vp8l) { fr.vp8l = r.data.vp8l; fr.type = constants.TYPE_LOSSLESS; }
break;
}
this.anim.frames[frame].width = r.width;
this.anim.frames[frame].height = r.height;
fr.width = r.width;
fr.height = r.height;
}
async muxAnim({ path, bgColor = [255,255,255,255], loops = 0, exif = false, iccp = false, xmp = false }={}) { return Image.muxAnim({ path, bgColor, loops, frames: this.frames, exif: exif ? this.exif : undefined, iccp: iccp ? this.iccp : undefined, xmp: xmp ? this.xmp : undefined }); }
async muxAnim({ path, bgColor = this.hasAnim ? this.anim.backgroundColor : [255,255,255,255], loops = this.hasAnim ? this.anim.loopCount : 0, exif = !!this.exif, iccp = !!this.iccp, xmp = !!this.xmp, width = this.width, height = this.height }={}) { return Image.muxAnim({ path, bgColor, loops, frames: this.frames, width, height, exif: exif ? this.exif : undefined, iccp: iccp ? this.iccp : undefined, xmp: xmp ? this.xmp : undefined }); }
async save(path = this.path) { return Image.save(path, this); }

@@ -285,2 +288,3 @@

out.vp8 = this.#readChunk_VP8_buf(buf, header.size, cursor);
if (out.alph) { out.vp8.alpha = true; }
}

@@ -295,5 +299,5 @@ break;

case 'ALPH':
if (out.vp8) {
if (!out.alph) {
out.alph = this.#readChunk_ALPH_buf(buf, header.size, cursor);
out.vp8.alpha = true;
if (out.vp8) { out.vp8.alpha = true; }
}

@@ -314,3 +318,3 @@ break;

#readChunk_ALPH_buf(buf, size, cursor) {
if (cusor >= buf.length) { throw new Error('Reached end of buffer while reading ALPH chunk'); }
if (cursor >= buf.length) { throw new Error('Reached end of buffer while reading ALPH chunk'); }
return { raw: buf.slice(cursor, cursor+size) };

@@ -320,3 +324,3 @@ }

async #readChunk_EXIF(fd, size) { return this.#readChunk_raw('EXIF', fd, size); }
async #readChunk_XMP(fd, size) { return this.#readChunk_raw('XML', fd, size); }
async #readChunk_XMP(fd, size) { return this.#readChunk_raw('XMP ', fd, size); }
async #readChunk_Skip(fd, size) {

@@ -557,3 +561,3 @@ let buf = Buffer.alloc(size), discard = Buffer.alloc(1);

header.writeUInt32LE(size, 4);
if (alpha) { out[1][8] |= 0b00010000; }
if (alpha) { vp8x[8] |= 0b00010000; }
let fp = await fs.open(path, 'w');

@@ -560,0 +564,0 @@ for (let i = 0, l = out.length; i < l; i++) { await fs.write(fp, out[i], 0, undefined, undefined); }