Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gif-encoder

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gif-encoder - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

2

CHANGELOG.md
# gif-encoder changelog
0.4.0 - Broke down `getImagePixels` into `removeAlphaChannel` and `setImagePixels`
0.3.0 - Moved to readable-stream for streams1/streams2 functionality

@@ -3,0 +5,0 @@

38

lib/GIFEncoder.js

@@ -97,3 +97,2 @@ /*

this.image = null; // current frame
this.pixels = null; // BGR byte array from frame

@@ -179,5 +178,4 @@ this.indexedPixels = null; // converted frame indexed to palette

GIFEncoder.prototype.analyzeImage = function (imageData) {
this.image = imageData;
this.getImagePixels(); // convert to correct format if necessary
// convert to correct format if necessary
this.setImagePixels(this.removeAlphaChannel(imageData));
this.analyzePixels(); // build color table & map pixels

@@ -323,10 +321,7 @@ };

*/
// TODO: Require an input for this and make option for clone (default: true)
// allows for optimization with trade off of mutation
GIFEncoder.prototype.getImagePixels = function() {
GIFEncoder.prototype.removeAlphaChannel = function (data) {
var w = this.width;
var h = this.height;
this.pixels = new Uint8Array(w * h * 3);
var pixels = new Uint8Array(w * h * 3);
var data = this.image;
var count = 0;

@@ -337,24 +332,13 @@

var b = (i * w * 4) + j * 4;
this.pixels[count++] = data[b];
this.pixels[count++] = data[b+1];
this.pixels[count++] = data[b+2];
pixels[count++] = data[b];
pixels[count++] = data[b+1];
pixels[count++] = data[b+2];
}
}
return pixels;
};
GIFEncoder.prototype._pixelHack = function(data) {
var w = this.width;
var h = this.height;
this.pixels = new Uint8Array(w * h * 3);
var count = 0;
for (var i = 0; i < h; i++) {
for (var j = 0; j < w; j++) {
var b = (i * w * 4) + j * 4;
this.pixels[count++] = data.charCodeAt(b) - 33;
this.pixels[count++] = data.charCodeAt(b+1) - 33;
this.pixels[count++] = data.charCodeAt(b+2) - 33;
}
}
GIFEncoder.prototype.setImagePixels = function(pixels) {
this.pixels = pixels;
};

@@ -361,0 +345,0 @@

{
"name": "gif-encoder",
"description": "Streaming GIF encoder",
"version": "0.3.0",
"version": "0.4.0",
"homepage": "https://github.com/twolfson/gif-encoder",

@@ -6,0 +6,0 @@ "author": {

@@ -192,3 +192,3 @@ # gif-encoder [![Build status](https://travis-ci.org/twolfson/gif-encoder.png?branch=master)](https://travis-ci.org/twolfson/gif-encoder)

#### `analyzeImage(imageData)`
First part of `addFrame`; saves `imageData` to `this.image`, runs `getImagePixels()`, and runs `analyzePixels()`.
First part of `addFrame`; runs `setImagePixels(removeAlphaChannel(imageData))` and runs `analyzePixels()`.

@@ -199,5 +199,13 @@ - imageData `Array` - Same as that in [`addFrame`][]

#### `getImagePixels()`
Clones `this.image` into `image.pixels` as a `Uint8Array`. Totally unnecessary and non-performant method which is soon to be deprecated.
#### `removeAlphaChannel(imageData)`
Reduces `imageData` into a `Uint8Array` of length `3 * width * height` containing sequences of `r, g, b`; removing the alpha channel.
- imageData `Array` - Same as that in [`addFrame`][]; array containing `r, g, b, a` sequences.
#### `setImagePixels(pixels)`
Save `pixels` as `this.pixels` for image analysis.
- pixels `Array` - Same as `imageData` from [`addFrame`][]
- **`GifEncoder` will mutate the original data.**
#### `writeImageInfo()`

@@ -211,13 +219,2 @@ Second part of `addFrame`; behavior varies on if it is the first frame or following frame.

#### `setImagePixels(pixels, [options])`
`// TODO: Make this method.`
*This method has not yet been written but will be the one to deprecate `getImagePixels`.*
- pixels `Array` - Same as `imageData` from [`addFrame`][]
- options `Object` - Optional container for flags to alter behavior
- clone `Boolean` - If true (default), clone `pixels` into a `Uint8Array`. If false, save `pixels` directly as `this.pixels`
- **`GifEncoder` will mutate the original data.**
## Donating

@@ -224,0 +221,0 @@ Support this project and [others by twolfson][gittip] via [gittip][].

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