JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1443
  • Score
    100M100P100Q115594F
  • License (CC0-1.0 AND Apache-2.0 AND BSD-3-Clause)

Codecs for NodeJS

Package Exports

  • @astropub/codecs
  • @astropub/codecs/avif
  • @astropub/codecs/jpg
  • @astropub/codecs/jxl
  • @astropub/codecs/png
  • @astropub/codecs/resize
  • @astropub/codecs/webp
  • @astropub/codecs/wp2

Readme

Codecs

Codecs lets you use read, write, and edit different image formats.

npm install @astropub/codecs

Usage

import * as fs from 'node:fs/promises'
import * as codecs from '@astropub/codecs'

/** Decoded JPG. */
const image = await codecs.jpg.decode(
  await fs.readFile(
    new URL('./kitten.jpg', import.meta.url)
  )
)

image.data // UUint8ClampedArray of the decoded JPG
image.width // Width of the decoded JPG
image.height // Height of the decoded JPG

// WebP encode the image
await fs.writeFile(
  new URL('./kitten.webp', import.meta.url),
  await codecs.webp.encode(image, image.width, image.height)
)

Individual exports are also available.

import * as avif from '@astropub/codecs/avif'
import * as jpg from '@astropub/codecs/jpg'
import * as jxl from '@astropub/codecs/jxl'
import * as png from '@astropub/codecs/png'
import * as webp from '@astropub/codecs/webp'
import * as wp2 from '@astropub/codecs/wp2'
import * as resize from '@astropub/codecs/resize'

License

Codecs is a remix of Squoosh!.

Code original to this project is licensed under the CC0-1.0 License.

Code from Squoosh! is licensed under the Apache-2.0 License, Copyright Google Inc.

Code from Avif Encoder is licensed under the BSD License (BSD), Copyright Joe Drago.

Code from MozJPEG is licensed under the Modified (3-clause) BSD License (BSD), Copyright Viktor Szathmáry.

Code from JXL is licensed under the Apache-2.0 License, Copyright Google Inc.

Code from OxiPNG is licensed under the MIT License (MIT), Copyright Joshua Holmer.

Code from WebP is licensed under the Modified (3-clause) BSD License (BSD), Copyright Google Inc.

Code from WebP2 is licensed under the Apache-2.0 License, Copyright Google Inc.