npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xgify

v1.0.4

Published

Gifsicle promise-buffer-based wrapper for Node.js

Downloads

21

Readme

banner

Gifsicle promise-buffer-based wrapper for Node.js

import { xGify } from "xgify";

const gifBuffer = fs.readFileSync("input.gif");

const gif = new xGify(gifBuffer);

gif.prettySize; // 692 kB

await gif.scale(0.75);
await gif.colors(128);

gif.prettySize; // 406 kB

fs.writeFileSync("output.gif", gif.fileBuffer);

Instalation

npm install xgify

Features

xGify allows you to manipulate gifs in a simple way with a promise-based API. It uses the gifsicle binary to perform the operations.

Available methods:

  • stretchToFit: Stretches the gif to square dimensions

    await xGify.stretchToFit();
  • centerSquareCrop: Crops the gif to the center with square dimensions

    await xGify.centerSquareCrop();
  • lossy: Uses lossy compression to reduce file size with cost of quality (0-200)

    await xGify.lossy(120);
  • colors: Reduce the numbr of colors in the gif (2-256)

    await xGify.colors(64);
  • crop: Crops the gif to the specified dimensions with provided cropping points or callback.

    await xGify.crop({ x1: 0, y1: 0, x2: 100, y2: 75 });
    
    // or use a callback which provide you current dimensions of the gif as argument
    
    await xGify.crop((frameDimensions) => {
      // frameDimensions: {width: number, height: number}
      const newWidth = Math.floor(frameDimensions.width / 2);
      const newHeight = Math.floor(frameDimensions.height / 2);
      return { x1: 0, y1: 0, x2: newWidth, y2: newHeight };
    });
  • scale: Scale the gif by the percentage

    await xGify.scale(0.5); // 50%
    await xGify.scale(0.23); // 23%
  • cut: Cut the gif to the specified frames with provided [start, end] frames or callback.

    await xGify.cut([0, 200]);
    
    // or use a callback which provide you the number of frames in the gif as argument
    
    await xGify.cut((totalFrames) => {
      const halfFrames = Math.floor(totalFrames / 2);
      return [0, halfFrames];
    });
  • frameRate: reduce the frame rate of the gif, providing the value 2 will remove every second frame in the gif and also multiply the delay of each frame by 2.

    await xGify.metadata(); // frames: 250, delay: 10ms
    await xGify.frameRate(2); // frames: 125, delay: 20ms
  • rotate: rotate the gif by 90, 180 or 270 degrees

    await xGify.rotate(90);
  • metadata: get the metadata of the gif

    await xGify.metadata();
    // {
    //   delay: 7,
    //   frames: 60,
    //   height: 128,
    //   width: 228,
    //   duration: 420,
    //   fps: 14,
    //   size: 691708,
    //   prettySize: '692 kB'
    // }

Contributing

Feel free to open an issue or a pull request if you have any ideas or suggestions.

License

MIT