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

gifken

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gifken - npm Package Compare versions

Comparing version 2.1.1 to 3.0.3

crate/nodejs/gifken_bg.wasm

93

package.json
{
"name": "gifken",
"version": "2.1.1",
"description": "TypeScript / JavaScript GIF parser and maker",
"main": "lib/gifken.cjs",
"module": "lib/gifken.mjs",
"browser": "lib/gifken.umd.js",
"types": "lib/src/index.d.ts",
"version": "3.0.3",
"description": "JavaScript library that can reverse and split animated GIFs",
"type": "commonjs",
"homepage": "https://aaharu.github.io/gifken/",
"main": "./dist/node.js",
"module": "./dist/gifken.mjs",
"exports": {
".": {
"import": "./dist/gifken.mjs",
"require": "./dist/node.js"
}
},
"types": "./dist/gifken.d.ts",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"test": "jest",
"pretest": "rimraf coverage",
"clean": "rimraf lib coverage",
"lint": "eslint --ext .ts --ignore-path .gitignore .",
"lint:fix": "eslint --fix --ext .ts --ignore-path .gitignore .",
"predoc": "rimraf docs",
"doc": "typedoc --target es2015 --module commonjs --out docs --readme README.md src && node d.js",
"release": "standard-version"
"wasm": "npm --prefix \"crate\" run build",
"predev": "npm run wasm",
"dev": "vite",
"build": "run-s clean wasm build:web build:nodejs",
"build:web": "vite build",
"build:nodejs": "tsc ./src/node.ts --module commonjs --outDir dist --target es2017",
"clean": "rimraf dist crate/nodejs crate/web crate/target",
"lint": "xo",
"prepare": "is-ci || husky install"
},

@@ -33,35 +36,22 @@ "repository": {

"engines": {
"node": ">=8.0.0"
"node": ">=14"
},
"dependencies": {
"browser-or-node": "^1.2.1"
},
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@types/jest": "^25.2.1",
"@types/node": "^12.12.35",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"codecov": "^3.6.5",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-prettier": "^3.1.3",
"husky": "^4.2.5",
"jest": "^25.3.0",
"lint-staged": "^10.1.3",
"prettier": "^2.0.4",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"husky": "^8.0.1",
"is-ci": "^3.0.1",
"lint-staged": "^13.0.3",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"rollup": "^2.6.1",
"rollup-plugin-typescript2": "^0.26.0",
"standard-version": "^7.1.0",
"ts-jest": "^25.3.1",
"typedoc": "^0.17.4",
"typescript": "^3.8.3"
"typescript": "^4.8.3",
"vite": "^3.1.0",
"vite-plugin-dts": "^1.5.0",
"xo": "^0.52.3"
},
"files": [
"lib",
"src"
"dist/*.ts",
"dist/*.js",
"dist/*.mjs",
"crate/nodejs"
],

@@ -71,14 +61,3 @@ "keywords": [

"gif"
],
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.ts": [
"npm run lint:fix"
]
}
]
}
# gifken
[![npm version](https://img.shields.io/npm/v/gifken.svg)](https://www.npmjs.com/package/gifken) [![Build Status](https://img.shields.io/travis/aaharu/gifken.svg)](https://travis-ci.org/aaharu/gifken) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faaharu%2Fgifken.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Faaharu%2Fgifken?ref=badge_shield) [![codecov](https://codecov.io/gh/aaharu/gifken/branch/master/graph/badge.svg)](https://codecov.io/gh/aaharu/gifken)
[![npm version](https://img.shields.io/npm/v/gifken.svg)](https://www.npmjs.com/package/gifken) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faaharu%2Fgifken.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Faaharu%2Fgifken?ref=badge_shield)
## How to use
### Create a GIF image in browser
### Split an animated GIF image in browser
```html
<div id="content"></div>
<script src="https://unpkg.com/gifken@2.0.0/lib/gifken.umd.js"></script>
<script type="application/javascript">
window.onload = () => {
var newgif = new gifken.Gif();
newgif.width = 100;
newgif.height = 100;
newgif.globalColorTable = gifken.GifColor.createColorTable([
new gifken.GifColor(0, 0, 0),
new gifken.GifColor(255, 0, 0),
new gifken.GifColor(0, 255, 0),
new gifken.GifColor(0, 0, 255),
new gifken.GifColor(100, 100, 255),
new gifken.GifColor(100, 255, 100),
new gifken.GifColor(255, 100, 100),
new gifken.GifColor(0, 255, 255),
new gifken.GifColor(255, 0, 255),
new gifken.GifColor(255, 255, 0),
new gifken.GifColor(255, 255, 255)
]);
newgif.frames = [gifken.GifFrame.init(newgif.width, newgif.height)];
for (var i = 0; i < newgif.frames[0].pixelData.length; ++i) {
newgif.frames[0].pixelData[i] = i % 11;
}
var newimg = new Image();
<script type="module">
import {reverse, split} from 'gifken'
// createObjectURL pattern
// var blob = gifken.GifPresenter.writeToBlob(newgif.writeToArrayBuffer());
// newimg.src = URL.createObjectURL(blob);
const imageUrl = '/01_Koch-Kurve-Sechseck-alt._Def.-2.gif'
const response = await fetch(imageUrl)
const buffer = await response.arrayBuffer()
// data-URL pattern
newimg.src = gifken.GifPresenter.writeToDataUrl(newgif.writeToArrayBuffer());
document.getElementById("content").appendChild(newimg);
};
const results = await split(new Uint8Array(buffer))
for (const result of results) {
const img = new Image()
img.src = URL.createObjectURL(new Blob([result], {type: 'image/gif'}))
document.body.append(img)
}
</script>
```
### Split an animated GIF image in browser
### Reverse an animated GIF image with Node.js
```javascript
window.onload = function () {
var xhr = new XMLHttpRequest();
xhr.open("GET", GIF_IMAGE_URL, true);
xhr.responseType = "arraybuffer";
xhr.onload = function (e) {
var arrayBuffer = e.target["response"];
var gif = gifken.Gif.parse(arrayBuffer);
const {readFileSync, writeFileSync} = require('fs')
const gifken = require('gifken')
gif.split(true).forEach(function (i) {
var img = new Image();
var blob = gifken.Gif.writeToBlob(i.writeToArrayBuffer());
img.src = URL.createObjectURL(blob);
document.getElementById("content").appendChild(img);
});
};
xhr.send();
};
gifken
.reverse(readFileSync('./assets/01_Koch-Kurve-Sechseck-alt._Def.-2.gif'))
.then(result => {
writeFileSync('reverse.gif', result)
})
```
### Create a GIF image by Node.js
```bash
npm install gifken
```
```javascript
const gifken = require("gifken"),
fs = require("fs"),
path = require("path");
const newgif = new gifken.Gif();
newgif.width = 100;
newgif.height = 100;
newgif.globalColorTable = gifken.GifColor.createColorTable([
new gifken.GifColor(0, 0, 0),
new gifken.GifColor(255, 0, 0),
new gifken.GifColor(0, 255, 0),
new gifken.GifColor(0, 0, 255),
new gifken.GifColor(100, 100, 255),
new gifken.GifColor(100, 255, 100),
new gifken.GifColor(255, 100, 100),
new gifken.GifColor(0, 255, 255),
new gifken.GifColor(255, 0, 255),
new gifken.GifColor(255, 255, 0),
new gifken.GifColor(255, 255, 255)
]);
newgif.frames = [gifken.GifFrame.init(newgif.width, newgif.height)];
for (let i = 0; i < newgif.frames[0].pixelData.length; ++i) {
newgif.frames[0].pixelData[i] = i % 11;
}
const buffer = newgif.writeToArray();
fs.writeFile(
path.resolve(__dirname, "sample.gif"),
Buffer.from(buffer),
err => {
if (err) throw err;
// eslint-disable-next-line no-console
console.log("It's saved!");
}
);
```
- [API Docs](http://aaharu.github.io/gifken/docs/)
## Build

@@ -120,4 +43,6 @@

- Node.js >=8.0.0
- npm
- Node.js >=14
- npm >=8
- [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)
- wasm-bindgen

@@ -128,3 +53,3 @@ ```bash

npm install
npm run-script build
npm run build
```

@@ -134,3 +59,3 @@

* [omggif](https://github.com/deanm/omggif)
- [gif reverser](https://github.com/migerh/rustwasm-gif)

@@ -137,0 +62,0 @@ ## License

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