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-optimizer

v1.2.0

Published

Optimizes APNG animations for js

Downloads

6

Readme

APNG-Optimizer

基于 WebAssembly 的 APNG 图片压缩工具。

底层基于 libimagequantAPNG Optimizer

运行 demo

npm run demo

demo

如何使用

在开始使用前,我们需要配置我们的打包工具(如 webpack)来支持加载 WebAssembly:

module.exports = {
    module: {
        rules: [{
            test: /\.wasm$/,
            use: [{
                loader: 'file-loader'
            }]
        }]
    }
}
import { APNGOptimizer } from 'apng-optimizer';
import assemblyPath from 'apng-optimizer/dist/apng-optimizer.wasm';

APNGOptimizer.createOptimizer(assemblyPath)
    .then(optimizer => {
        // ... load your apng image as buffer
        const uint8Array = new Uint8Array(buffer);
        const optAPNGArray = optimizer.optAPNG(uint8Array, {

            minQuality: 0,
            maxQuality: 100,
            processCallback: function(progerss) {
                console.log(progress); // 0.1231111
            }
        });
        const blob = new Blob([optAPNGArray.buffer], { type: 'image/png' });
        const url = URL.createObjectURL(blob);
        img.src = url;
    });

API

APNGOptimizer.createOptimizer(modulePath: string): Promise

通过加载 modulePath 路径上的 WebAssembly 来创建一个新的压缩器实例

APNGOptimizer.#optAPNG(apngBuffer: Uint8Array, options?: OptimizerOptions): Uint8Array

压缩 apng 图片

  • apngBuffer: apng 图像文件的 buffer 数据
  • options: 优化配置
    • deflateMethod(number): 选择压缩算法 0: zlib, 1: 7zip, 2: zopfli,默认为 1
    • iter(number): 使用压缩算法的迭代次数,默认为 15
    • minQuality(number): 使用 imagequant 进行色板取色的最小质量,默认为 0
    • maxQuality(number): 使用 imagequant 进行色斑取色的最大质量,默认为 100
    • disabledQuant(boolean): 禁用 imagequant,禁用后 minQualitymaxQuality 将会无效
    • processCallback((progress: number) => void): 压缩进度回调,progress 为当前压缩进度( 0 ~ 1)