Giter Club home page Giter Club logo

jay-peg's Introduction

jay-peg

Overview

A blazing-fast and compact JavaScript library dedicated to efficiently decoding JPEG images.

Installation

Using npm:

npm install jay-peg

Using yarn:

yarn add jay-peg

Usage

Use the decoder providing a JPEG data buffer as input.

import JPEG from 'jay-peg';

const jpegBuffer = /* your JPEG buffer here */;
const imageMarkers = JPEG.decoder(jpegBuffer);

console.log(imageMarkers);

Example Output

The output consists of a structured array of image markers:

[
  {
    type: 65496,
    name: "SOI",
  },
  {
    type: 65505,
    name: "EXIF",
    length: 16382,
    identifier: "Exif\x00\x00",
    entries: [Object],
  },
  {
    type: 65499,
    name: "DAC",
    length: 132,
    tables: [[Object], [Object]],
  },
  // ... and so forth
  {
    type: 65497,
    name: "EOI",
  },
];

API

decoder(buffer: Buffer | Uint8Array): Array<ImageMarker>

The decoder function accepts a JPEG buffer as its sole argument and returns an array of image markers.

Parameters

  • buffer: A Buffer or Uint8Array containing the JPEG image data.

Returns

An array of objects representing various markers found in the JPEG image.

ImageMarker

Each ImageMarker object in the output array adheres to the following structure:

  • type (Number): The marker type.
  • name (String): The marker name.
  • length (Number): The length of the marker data.
  • Additional properties specific to certain marker types.

Performance

Performance is a key focus of `jay-peg``. In a benchmark test using a 2448×3264, 2.2MB JPEG image, the decoding speed was measured as follows:

Benchmarked: small:  x 11,597 ops/sec ±0.60% (95 runs sampled)
Benchmarked: medium:  x 11,219 ops/sec ±0.20% (98 runs sampled)
Benchmarked: large:  x 7,744 ops/sec ±0.27% (100 runs sampled)
Benchmarked: huge:  x 2,019 ops/sec ±0.36% (96 runs sampled)

It's worth noting that the performance is significantly improved on smaller and simpler images.

License

jay-peg is released under the MIT License

jay-peg's People

Contributors

diegomura avatar adellamanocco avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.