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

apng-handler

v0.1.4

Published

decode and encode (a)png in modern browser environment 🌐.

Downloads

23

Readme

English | 简体中文

apng-handler

decode and encode (a)png in modern browser environment 🌐. Including:

  1. (decode)get png frames from apng buffer
  2. (encode)assemble png buffers to apng buffer

Intro

We have already used a great library -- apng-canvas in our production environment. It gives you ability to control apng playing behavior. Generally, I spend most of my time on normal logic codes. I hardly get the chance to know blob, buffer and bitwise operation while this lib has few annotation. We need more references to know more about(a)png. I learned this lib and add lots of annotation to it.

Additionally, I wrote a snippet of assemble apng buffer from png buffers, which runs in browser environment.

Usage

Currently this package doesn't offer enough abilities. But I still publish it to npm, in case that you want to try it out.

Install

  • install as a node_module
npm install apng-handler --save
  • use cdn
<script src="https://unpkg.com/apng-handler@{{version}}/dist/index.js"></script>

demo

// window.ApngHandler
import { apngDecoder, apngAssembler } from 'apng-handler';

const appendImg = (buf: ArrayBuffer) => {
  const img = document.createElement('img');
  img.width = 100;
  const url = URL.createObjectURL(
    new Blob([new Uint8Array(buf)], { type: 'image/apng' })
  );
  img.src = url;
  document.body.appendChild(img);
};

const blob = apngAssembler({
  buffers: [],// image buffers
  width: 302,
  height: 192,
});

blob.arrayBuffer().then((buf) => {
  appendImg(buf);
  apngDecoder(buf).then((blobs) => {
    blobs.forEach((b) => {
      b.arrayBuffer().then((_b) => {
        appendImg(_b);
      });
    });
  });
});
    

More References

  1. APNG Specification

    Most important ref, explained specification of apng compared to png.

  2. W3C PNG Spec

    W3C specification. Must learn to know deep about png structure. I just learned some conception stuff without reading through. When using compression techs, I suppose I have to go back to this ref.

  3. APNG Wiki

    that picture has been referred by many articles (I posted it in README)

  4. Web 端 APNG 播放实现原理

    including a great picture, mainly explaining apng-canvas lib

  5. ezgif.com

    online tool of processing apng and gif

  6. APNG Assembler

    application of generating apng

  7. Join up PNG images to an APNG animated image

    an answer about encoding approach in Node environment

  8. UPNG.js

    I used once but failed, perhaps I used it wrong. The code is also hard to understand. I didn't go deep.

Tail

💓 Plz feel free to make pr to add more functions of handling apng like compressing, clipping and coloring, etc.