npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

bare-jpeg

1.1.2

@GitHub Actions

npmHomeRepoSnykSocket
Downloads:856
$ npm install bare-jpeg
DailyWeeklyMonthlyYearly

bare-jpeg

JPEG support for Bare.

npm i bare-jpeg

Usage

const jpeg = require('bare-jpeg')

const image = require('./my-image.jpg', { with: { type: 'binary' } })

const decoded = jpeg.decode(image)
// {
//   width: 200,
//   height: 400,
//   data: <Buffer>
// }

const encoded = jpeg.encode(decoded)
// <Buffer>

Header:

const header = jpeg.readHeader(image)
// {
//   width: 200,
//   height: 400,
//   colorSpace: 3,
//   ...
//   markers: [{ marker: 224, data: <Buffer> }, ...] // APP0-APP15 and COM
// }

Utility to replace markers:

const newImage = jpeg.replaceMarkers(image, [
  { marker: 0xfe, data: Buffer.from('This is a comment') }
])
// <Buffer>

replaceMarkers() returns a new image, replacing the existing APP0-APP15 and COM markers without re-encoding the pixel data.

License

Apache-2.0