Socket
Socket
Sign inDemoInstall

gif-frames

Package Overview
Dependencies
71
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.3 to 0.2.4

CHANGELOG.md

7

gif-frames.js

@@ -59,3 +59,6 @@ var path = require('path');

getPixels(url, 'image/gif', function (err, pixels) {
// Necessary to check if we're in Node or the browser until this is fixed:
// https://github.com/scijs/get-pixels/issues/33
var inputType = typeof window === 'undefined' ? 'image/gif' : '.GIF';
getPixels(url, inputType, function (err, pixels) {
if (err) {

@@ -76,3 +79,3 @@ reject(err);

frameData.push({
getImageStream: function () {
getImage: function () {
return savePixels(pixels.pick(frameIndex), outputType, {

@@ -79,0 +82,0 @@ quality: quality

{
"name": "gif-frames",
"version": "0.2.3",
"version": "0.2.4",
"description": "Pure JavaScript tool for extracting GIF frames and saving to file",

@@ -5,0 +5,0 @@ "main": "gif-frames.js",

@@ -20,3 +20,3 @@ # gif-frames

gifFrames({ url: 'image.gif', frames: 0 }).then(function (frameData) {
frameData[0].getImageStream().pipe(fs.createWriteStream('firstframe.jpg'));
frameData[0].getImage().pipe(fs.createWriteStream('firstframe.jpg'));
});

@@ -46,3 +46,3 @@ ```

{
getImageStream,
getImage,
frameIndex

@@ -52,2 +52,12 @@ }

### `getImage()`
Returns one of:
* A drawn canvas DOM element, if `options.outputType` is `'canvas'`
* A data stream which can be piped to file output, otherwise
### `frameIndex`
The index corresponding to the frame's position in the original GIF (not necessarily the same as the frame's position in the result array)
## Examples

@@ -68,3 +78,3 @@

frameData.forEach(function (frame) {
frame.getImageStream().pipe(fs.createWriteStream(
frame.getImage().pipe(fs.createWriteStream(
'image-' + frame.frameIndex + '.png'

@@ -84,6 +94,4 @@ ));

.then(function (frameData) {
var canvas = document.createElement('canvas');
document.body.appendChild(canvas);
frameData[0].getImageStream().pipe(canvas);
document.body.appendChild(frameData[0].getImage());
}).catch(console.error.bind(console));
```
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc