gif-frames
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -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)); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9196
6
84
93