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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@keeex/jpegfix

v1.0.2

Published

Recovery tool to retrieve picture data from damaged jpeg files

Downloads

12

Readme

@keeex/jpegfix

Recovery tool to retrieve picture data from damaged jpeg files. Basic operation is looking through the file for the essential blocks and create a hopefully viable output with the image content.

Metadata and other custom fields will be stripped.

Usage

The CLI tool can be used to process individual images. There is a built-in help, but the most useful command is:

You can either install it globally:

npm install -g @keeex/jpegfix
jpegfix -i <input file>

Run it from npx:

npx @keeex/jpegfix -i <input file>

Clone the repository and run it from there:

git clone [email protected]:KeeeX/jpegfix.git
cd jpegfix
npm ci
npm start -- -i <input file>

Run the CLI in TypeScript for debugging purpose (with cloned repository):

git clone [email protected]:KeeeX/jpegfix.git
cd jpegfix
npm ci
./devrun.sh -i <input file>

Or use it as a library (see below).

The CLI command will automatically use <basename input file>.orig.jpg as the output.

Behavior

This tool tries to retrieve only the visual data and explicitely kills any "extra" sections besides these.

To avoid malformed metadata actually containing a thumbnail in JPEG form, the algorithm first look for a plausible JPEG file inside the JPEG file, and excludes this area when searching actual picture data. Best case scenario, the expected fields can be detected and the original visual can be retrieved. The following outlines the "degraded" recovery modes that this program will recover:

  • stripping any non-essential fields
  • missing beginning of file
  • missing end of file
  • broken thumbnail messing with detection
  • fallback to the thumbnail if the original data is irrecoverable and a thumbnail exists, with same process

In particular, no attempt is done to save the extra metadata (EXIF/JFIF).

Library usage

The library exposes two main functions, one to analyze a file and one to rebuild a JPEG.

Here's a short example:

import {analyzeJpeg, rebuildJpeg} from "@keeex/jpegfix";
import {readFileSync} from "fs";

const buffer = readFileSync("somefile.jpg");
const analyze = analyzeJpeg(buffer);
const rebuiltImage = rebuildJpeg(buffer);

Some more advanced functions can be called to customize the process, but that should not be necessary.