Skip to content

nickesc/animwebp

Repository files navigation

Source: Github Tests: github.com/nickesc/animwebp/actions/workflows/ts-tests.yml
NPM: npmjs.com/package/animwebp

animwebp


About

Convert a sequence of images to an animated WebP. Supports .png, .jpeg, .tiff and .webp files.

Install

Install animwebp via npm.

To install animwebp as a library in a JavaScript or TypeScript project:

npm install animwebp

To install animwebp globally, for use as a CLI tool:

npm install -g animwebp

CLI Usage

Usage: animwebp [options] <files...>

Convert a sequence of images to an animated WebP.

Arguments:
  files                       list of paths to image files (ex.: use *.png to
                              select all png files in a directory)

Options:
  -o, --output <path>         required; output path for the animated webp file

ANIMATION
  -f, --frame-delay <number>  delay between frames, in milliseconds (default:
                              "1000")
  -q, --quality <number>      quality level, lower values result in more
                              compression; 0-100 (default: "100")
  -w, --width <number>        frame width; if only width is set, height scales
                              proportionally
  -h, --height <number>       frame height; if only height is set, width scales
                              proportionally

LOGGING
  -v, --verbose               print logs to stdout

INFORMATION
  -V, --version               output the version number
  --help                      display help for animwebp

Reference

animwebp

Library and command-line tool for converting lists of images to animated WebP files.

Example

import { animate_webp } from 'animwebp';
let out = `anim.webp`
let imgs = ['1.jpg', '2.png', '3.png', '4.png', '5.png']

// generate a webp with logging on, 2000ms frame delay,
// a height of 1024 pixels and an automatic width
animate_webp(imgs, out, true, 2000, undefined, 1024)

animwebp.animate_webp(input, output, [logging], [frameDelay], [quality], [width], [height]) ⇒ Promise.<string>

Convert a sequence of images to an animated .webp file.

Kind: static method of animwebp
Returns: Promise.<string> - a Promise that resolves to the path of the animated webp file

Param Type Default Description
input Array.<string> list of paths to image files
output string output path for the animated webp file
[logging] boolean | undefined whether to print logs to stdout; if undefined orfalse , logs will not print
[frameDelay] number 1000 delay between frames, in milliseconds (default: 1000)
[quality] number 100 quality level, quality level, lower values result in more compression; 0-100 (default: 100)
[width] number | undefined frame width; if only width is set, height scales proportionally
[height] number | undefined frame height; if only height is set, width scales proportionally

Example

import { animate_webp } from 'animwebp';
let out = `anim.webp`
let imgs = ['1.jpg', '2.png']
animate_webp(imgs,out)

License

animwebp is released under the MIT license. For more information, see the repository's LICENSE file.

About

Convert a sequence of images to an animated WebP

Resources

License

Stars

Watchers

Forks