node-webpmux
Advanced tools
+1
-1
| { | ||
| "name": "node-webpmux", | ||
| "version": "3.1.4", | ||
| "version": "3.1.5", | ||
| "description": "A pure Javascript/WebAssembly re-implementation of webpmux", | ||
@@ -5,0 +5,0 @@ "main": "webp.js", |
+9
-6
@@ -97,5 +97,5 @@ # node-webpmux | ||
| ##### `async .replaceFrame(frame, source)` | ||
| ##### `async .replaceFrame(frameIndex, source)` | ||
| Replaces a frame in the animation with another image from `source`. All other frame settings are preserved. | ||
| * `frame`: Which frame to replace. Frame indexes are 0-based. | ||
| * `frameIndex`: Which frame to replace. Frame indexes are 0-based. | ||
| * `source`: If this is a string, the frame is loaded from disk. If this is a Buffer, the frame is loaded from there. | ||
@@ -113,6 +113,7 @@ | ||
| ##### `async .setImageData(buf, { width = 0, height = 0, preset = 0, quality = 75, exact = false, lossless = 0, method = 4, advanced = undefined })` | ||
| ##### `async .setImageData(buffer, { width = 0, height = 0, preset = 0, quality = 75, exact = false, lossless = 0, method = 4, advanced = undefined })` | ||
| Encode `buf` as a new WebP using the provided settings and replace the image pixel data with it.<br /> | ||
| This preserves EXIF/ICCP/XMP if present.<br /> | ||
| Use this for non-animations.<br /> | ||
| * `buffer`: A Buffer object with the raw pixels in RGBA order.<br /> | ||
| Options: | ||
@@ -231,10 +232,12 @@ * `width`/`height`<br /> | ||
| ##### `async .getFrameData(frame)` | ||
| ##### `async .getFrameData(frameIndex)` | ||
| Get the raw RGBA pixel data for a specific frame.<br /> | ||
| Use this for animations.<br /> | ||
| Otherwise identical to `.getImageData()`. | ||
| * `frameIndex`: Which frame to get. Frame indexes are 0-based.<br /> | ||
| Otherwise identical to `.getImageData()` | ||
| ##### `async .setFrameData(frame, buffer, { width = 0, height = 0, preset = 0, quality = 75, exact = false, lossless = 0, method = 4, advanced = undefined })` | ||
| ##### `async .setFrameData(frameIndex, buffer, { width = 0, height = 0, preset = 0, quality = 75, exact = false, lossless = 0, method = 4, advanced = undefined })` | ||
| Encode `buffer` as a new WebP using the provided settings and replace an existing frame's pixel data with it.<br /> | ||
| Use this for animations.<br /> | ||
| * `frameIndex`: Which frame to get. Frame indexes are 0-based.<br /> | ||
| Otherwise identical to `.setImageData()`. | ||
@@ -241,0 +244,0 @@ |
+12
-9
@@ -220,6 +220,7 @@ // For more information on the WebP format, see https://developers.google.com/speed/webp/docs/riff_container | ||
| } | ||
| async replaceFrame(frame, d) { | ||
| async replaceFrame(frameIndex, d) { | ||
| if (!this.hasAnim) { throw new Error("WebP isn't animated"); } | ||
| if ((frame < 0) || (frame >= this.frames.length)) { throw new Error(`Frame index ${frame} out of bounds (0 <= index < ${this.frames.length})`); } | ||
| let r = new Image(), fr = this.frames[frame]; | ||
| if (typeof frameIndex !== 'number') { throw new Error('Frame index expects a number'); } | ||
| if ((frameIndex < 0) || (frameIndex >= this.frames.length)) { throw new Error(`Frame index out of bounds (0 <= index < ${this.frames.length})`); } | ||
| let r = new Image(), fr = this.frames[frameIndex]; | ||
| await r.load(d); | ||
@@ -320,17 +321,19 @@ switch (r.type) { | ||
| } | ||
| async getFrameData(frame) { | ||
| async getFrameData(frameIndex) { | ||
| if (!Image.libwebp) { throw new Error('Must call Image.initLib() before using getFrameData'); } | ||
| if (!this.hasAnim) { throw new Error('Calling getFrameData on non-animations is not supported'); } | ||
| if ((frame < 0) || (frame >= this.frames.length)) { throw new Error('Frame index out of range'); } | ||
| let fr = this.frames[frame], buf = await this._demuxFrame(null, fr); | ||
| if (typeof frameIndex !== 'number') { throw new Error('Frame index expects a number'); } | ||
| if ((frameIndex < 0) || (frameIndex >= this.frames.length)) { throw new Error('Frame index out of range'); } | ||
| let fr = this.frames[frameIndex], buf = await this._demuxFrame(null, fr); | ||
| return Image.libwebp.decodeImage(buf, fr.width, fr.height); | ||
| } | ||
| async setFrameData(frame, buf, { width = 0, height = 0, preset = undefined, quality = undefined, exact = undefined, lossless = undefined, method = undefined, advanced = undefined } = {}) { | ||
| async setFrameData(frameIndex, buf, { width = 0, height = 0, preset = undefined, quality = undefined, exact = undefined, lossless = undefined, method = undefined, advanced = undefined } = {}) { | ||
| if (!Image.libwebp) { throw new Error('Must call Image.initLib() before using setFrameData'); } | ||
| if (!this.hasAnim) { throw new Error('Calling setFrameData on non-animations is not supported'); } | ||
| if ((frame < 0) || (frame >= this.frames.length)) { throw new Error('Frame index out of range'); } | ||
| if (typeof frameIndex !== 'number') { throw new Error('Frame index expects a number'); } | ||
| if ((frameIndex < 0) || (frameIndex >= this.frames.length)) { throw new Error('Frame index out of range'); } | ||
| if ((quality !== undefined) && ((quality < 0) || (quality > 100))) { throw new Error('Quality out of range'); } | ||
| if ((lossless !== undefined) && ((lossless < 0) || (lossless > 9))) { throw new Error('Lossless preset out of range'); } | ||
| if ((method !== undefined) && ((method < 0) || (method > 6))) { throw new Error('Method out of range'); } | ||
| let fr = this.frames[frame], ret = Image.libwebp.encodeImage(buf, width > 0 ? width : fr.width, height > 0 ? height : fr.height, { preset, quality, exact, lossless, method, advanced }), img = new Image(); | ||
| let fr = this.frames[frameIndex], ret = Image.libwebp.encodeImage(buf, width > 0 ? width : fr.width, height > 0 ? height : fr.height, { preset, quality, exact, lossless, method, advanced }), img = new Image(); | ||
| if (ret.res !== encodeResults.SUCCESS) { return ret.res; } | ||
@@ -337,0 +340,0 @@ await img.load(Buffer.from(ret.buf)); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
819090
0.07%1208
0.25%419
0.72%