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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jpeginfo-wrapper

v1.0.0

Published

TypeScript wrapper for jpeginfo command - prints information and tests integrity of JPEG/JFIF files

Readme

jpeginfo-wrapper

A TypeScript wrapper for the jpeginfo command-line tool that prints information and tests integrity of JPEG/JFIF files.

Features

  • 🖼️ Complete jpeginfo support - All command-line options and features
  • 📊 Multiple output formats - Normal, CSV, and JSON output
  • 🔍 Integrity testing - Test JPEG file integrity
  • 🔐 Checksum calculation - MD5, SHA-1, SHA-256, SHA-512
  • 🐳 Docker support - Ubuntu environment with jpeginfo pre-installed
  • 📝 TypeScript support - Full type definitions and IntelliSense
  • 🧪 Comprehensive testing - Jest test suite

Installation

Prerequisites

You need to have jpeginfo installed on your system. You can install it via:

Ubuntu/Debian:

sudo apt-get install jpeginfo

macOS:

brew install jpeginfo

From source:

git clone https://github.com/tjko/jpeginfo.git
cd jpeginfo
./configure
make
sudo make install

Install the package

npm install jpeginfo-wrapper

Quick Start

import { JpegInfo, getJpegInfo } from 'jpeginfo-wrapper';

// Using the class
const jpeginfo = new JpegInfo();
const result = await jpeginfo.getInfo('image.jpg');
console.log(result.data);

// Using convenience function
const info = await getJpegInfo(['image1.jpg', 'image2.jpg']);
console.log(info.data);

Usage Examples

Basic Information

import { JpegInfo } from 'jpeginfo-wrapper';

const jpeginfo = new JpegInfo();

// Get basic information about a JPEG file
const result = await jpeginfo.getInfo('photo.jpg');
console.log(result.data[0]);
// Output:
// {
//   filename: 'photo.jpg',
//   filesize: 1234567,
//   fileDate: '2023:12:25 10:30:45',
//   cameraMake: 'Canon',
//   cameraModel: 'EOS R5',
//   dateTime: '2023:12:25 10:30:45',
//   resolution: { width: 8192, height: 5464 },
//   flash: false,
//   focalLength: 50,
//   focalLength35mm: 50,
//   exposureTime: '1/125',
//   aperture: 'f/2.8',
//   ...
// }

Multiple Files

// Process multiple files
const result = await jpeginfo.getInfo(['photo1.jpg', 'photo2.jpg', 'photo3.jpg']);

// Process all JPEG files in a directory
const files = ['*.jpg']; // or use glob patterns
const result = await jpeginfo.getInfo(files);

Output Formats

// CSV output
const csvData = await jpeginfo.getCsvOutput('photo.jpg');
console.log(csvData);
// Output: Array of objects with CSV headers as keys

// JSON output
const jsonData = await jpeginfo.getJsonOutput('photo.jpg');
console.log(jsonData);
// Output: Array of objects in JSON format

// Concise output (single line per file)
const concise = await jpeginfo.getInfo('photo.jpg', { concise: true });

Integrity Testing

// Test file integrity
const integrity = await jpeginfo.testIntegrity('photo.jpg');
console.log(integrity);
// Output:
// {
//   success: true,
//   exitCode: 0,
//   validFiles: ['photo.jpg'],
//   invalidFiles: [],
//   errorDetails: {}
// }

// Test multiple files
const testResult = await jpeginfo.testIntegrity(['photo1.jpg', 'photo2.jpg']);
if (testResult.invalidFiles.length > 0) {
  console.log('Corrupted files:', testResult.invalidFiles);
}

Checksum Calculation

// Calculate MD5 checksum
const checksums = await jpeginfo.calculateChecksums('photo.jpg', ['md5']);
console.log(checksums[0].md5);

// Calculate multiple checksums
const multiChecksums = await jpeginfo.calculateChecksums('photo.jpg', ['md5', 'sha1', 'sha256']);
console.log(multiChecksums[0]);
// Output:
// {
//   filename: 'photo.jpg',
//   filesize: 1234567,
//   md5: 'd41d8cd98f00b204e9800998ecf8427e',
//   sha1: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
//   sha256: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
// }

Advanced Options

// Detailed information with all options
const detailed = await jpeginfo.getInfo('photo.jpg', {
  detailed: true,      // Show coding, density, CCIR601 sampling
  verbose: true,       // Verbose output
  md5: true,          // Calculate MD5
  sha256: true,       // Calculate SHA-256
  format: 'json',     // JSON output
  header: true        // Include headers
});

// Process files from stdin
const stdinResult = await jpeginfo.processStdin({ format: 'csv' });

// Process files from a file list
const fileListResult = await jpeginfo.processFromFile('filelist.txt');

API Reference

JpegInfo Class

Constructor

new JpegInfo(jpeginfoBinary?: string)
  • jpeginfoBinary (optional): Path to jpeginfo binary (default: 'jpeginfo')

Methods

getInfo(files, options?)

Get information about JPEG files.

async getInfo(
  files: string | string[], 
  options?: JpegInfoOptions
): Promise<JpegInfoResult>
testIntegrity(files)

Test integrity of JPEG files.

async testIntegrity(files: string | string[]): Promise<JpegInfoTestResult>
getCsvOutput(files, options?)

Get CSV formatted output.

async getCsvOutput(
  files: string | string[], 
  options?: Omit<JpegInfoOptions, 'format'>
): Promise<JpegInfoCsvOutput[]>
getJsonOutput(files, options?)

Get JSON formatted output.

async getJsonOutput(
  files: string | string[], 
  options?: Omit<JpegInfoOptions, 'format'>
): Promise<JpegInfoJsonOutput[]>
calculateChecksums(files, types?)

Calculate checksums for JPEG files.

async calculateChecksums(
  files: string | string[], 
  types?: ('md5' | 'sha1' | 'sha256' | 'sha512')[]
): Promise<JpegInfoChecksumOutput[]>

Options

JpegInfoOptions

interface JpegInfoOptions {
  concise?: boolean;           // Concise output (one line)
  verbose?: boolean;           // Verbose output
  quiet?: boolean;             // Quiet mode
  listingFormat?: boolean;     // Alternative listing format
  detailed?: boolean;          // Show detailed information
  test?: boolean;              // Test file integrity
  errorsOnly?: boolean;        // Show only files with errors
  md5?: boolean;               // Calculate MD5 checksum
  sha1?: boolean;              // Calculate SHA-1 checksum
  sha256?: boolean;            // Calculate SHA-256 checksum
  sha512?: boolean;            // Calculate SHA-512 checksum
  format?: 'normal' | 'csv' | 'json';  // Output format
  header?: boolean;            // Include column headers
  stdin?: boolean;             // Read from stdin
  filesFrom?: string;          // Read file list from file
  filesStdin?: boolean;        // Read file list from stdin
  files?: string[];            // Additional files to process
}

Docker Support

The package includes Docker support for testing and development:

# Build the Docker image
npm run docker:build

# Run tests in Docker
npm run docker:test

# Or run manually
docker run --rm -v $(pwd):/workspace jpeginfo-wrapper bash

The Docker image includes:

  • Ubuntu 22.04 LTS
  • Node.js 18.x LTS
  • jpeginfo v1.7.1 (latest)
  • All necessary build dependencies

Development

Setup

# Clone the repository
git clone https://github.com/your-username/jpeginfo-wrapper.git
cd jpeginfo-wrapper

# Install dependencies
npm install

# Build the project
npm run build

Testing

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

Code Quality

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

# Format code
npm run format

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

Related Projects

  • jpeginfo - The original jpeginfo command-line tool
  • exif-parser - EXIF data parser
  • sharp - High performance image processing

Support

If you encounter any issues or have questions:

  1. Check the issues page
  2. Create a new issue with detailed information
  3. Include your operating system, Node.js version, and jpeginfo version