• Stars
    star
    1,161
  • Rank 40,194 (Top 0.8 %)
  • Language
    C
  • Created almost 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Utilities for archiving JPEGs for long term storage.

JPEG Archive Build Status Build status Version License

Utilities for archiving photos for saving to long term storage or serving over the web. The goals are:

  • Use a common, well supported format (JPEG)
  • Minimize storage space and cost
  • Identify duplicates / similar photos

Approach:

  • Command line utilities and scripts
  • Simple options and useful help
  • Good quality output via sane defaults

Contributions to this project are very welcome.

Download

You can download the latest source and binary releases from the JPEG Archive releases page. Windows binaries for the latest commit are available from the Windows CI build server.

If you are looking for an easy way to run these utilities in parallel over many files to utilize all CPU cores, please also download Ladon or GNU Parallel. You can then use the jpeg-archive command below or use ladon directly. Example:

# Re-compress JPEGs and replace the originals
ladon "Photos/**/*.jpg" -- jpeg-recompress FULLPATH FULLPATH

# Re-compress JPEGs into the new directory 'Comp'
ladon -m Comp/RELDIR "Photos/**/*.jpg" -- jpeg-recompress FULLPATH Comp/RELPATH

Utilities

The following utilities are part of this project. All of them accept a --help parameter to see the available options.

jpeg-archive

Compress RAW and JPEG files in a folder utilizing all CPU cores. This is a simple shell script that uses the utilities below. It requires:

# Compress a folder of images
cd path/to/photos
jpeg-archive

# Custom quality and metric
jpeg-archive --quality medium --method smallfry

jpeg-recompress

Compress JPEGs by re-encoding to the smallest JPEG quality while keeping perceived visual quality the same and by making sure huffman tables are optimized. This is a lossy operation, but the images are visually identical and it usually saves 30-70% of the size for JPEGs coming from a digital camera, particularly DSLRs. By default all EXIF/IPTC/XMP and color profile metadata is copied over, but this can be disabled to save more space if desired.

There is no need for the input file to be a JPEG. In fact, you can use jpeg-recompress as a replacement for cjpeg by using PPM input and the --ppm option.

The better the quality of the input image is, the better the output will be.

Some basic photo-related editing options are available, such as removing fisheye lens distortion.

Demo

Below are two 100% crops of Nikon's D3x Sample Image 2. The left shows the original image from the camera, while the others show the output of jpeg-recompress with the medium quality setting and various comparison methods. By default SSIM is used, which lowers the file size by 88%. The recompression algorithm chooses a JPEG quality of 80. By comparison the veryhigh quality setting chooses a JPEG quality of 93 and saves 70% of the file size.

JPEG recompression comparison

Why are they different sizes? The default quality settings are set to average out to similar visual quality over large data sets. They may differ on individual photos (like above) because each metric considers different parts of the image to be more or less important for compression.

Image Comparison Metrics

The following metrics are available when using jpeg-recompress. SSIM is the default.

Name Option Description
MPE -m mpe Mean pixel error (as used by imgmin)
SSIM -m ssim Structural similarity DEFAULT
MS-SSIM* -m ms-ssim Multi-scale structural similarity (slow!) (2008 paper)
SmallFry -m smallfry Linear-weighted BBCQ-like (original project, 2011 BBCQ paper)

Note: The SmallFry algorithm may be patented so use with caution.

Subsampling

The JPEG format allows for subsampling of the color channels to save space. For each 2x2 block of pixels per color channel (four pixels total) it can store four pixels (all of them), two pixels or a single pixel. By default, the JPEG encoder subsamples the non-luma channels to two pixels (often referred to as 4:2:0 subsampling). Most digital cameras do the same because of limitations in the human eye. This may lead to unintended behavior for specific use cases (see #12 for an example), so you can use --subsample disable to disable this subsampling.

Example Commands

# Default settings
jpeg-recompress image.jpg compressed.jpg

# High quality example settings
jpeg-recompress --quality high --min 60 image.jpg compressed.jpg

# Slow high quality settings (3-4x slower than above, slightly more accurate)
jpeg-recompress --accurate --quality high --min 60 image.jpg compressed.jpg

# Use SmallFry instead of SSIM
jpeg-recompress --method smallfry image.jpg compressed.jpg

# Use 4:4:4 sampling (disables subsampling).
jpeg-recompress --subsample disable image.jpg compressed.jpg

# Remove fisheye distortion (Tokina 10-17mm on APS-C @ 10mm)
jpeg-recompress --defish 2.6 --zoom 1.2 image.jpg defished.jpg

# Read from stdin and write to stdout with '-' as the filename
jpeg-recompress - - <image.jpg >compressed.jpg

# Convert RAW to JPEG via PPM from stdin
dcraw -w -q 3 -c IMG_1234.CR2 | jpeg-recompress --ppm - compressed.jpg

# Disable progressive mode (not recommended)
jpeg-recompress --no-progressive image.jpg compressed.jpg

# Disable all output except for errors
jpeg-recompress --quiet image.jpg compressed.jpg

jpeg-compare

Compare two JPEG photos to judge how similar they are. The fast comparison method returns an integer from 0 to 99, where 0 is identical. PSNR, SSIM, and MS-SSIM return floats but require images to be the same dimensions.

# Do a fast compare of two images
jpeg-compare image1.jpg image2.jpg

# Calculate PSNR
jpeg-compare --method psnr image1.jpg image2.jpg

# Calculate SSIM
jpeg-compare --method ssim image1.jpg image2.jpg

jpeg-hash

Create a hash of an image that can be used to compare it to other images quickly.

jpeg-hash image.jpg

Building

Dependencies

Ubuntu

Ubuntu users can install via apt-get:

sudo apt-get install build-essential autoconf pkg-config nasm libtool
git clone https://github.com/mozilla/mozjpeg.git
cd mozjpeg
autoreconf -fiv
./configure --with-jpeg8
make
sudo make install

Mac OS X

Mac users can install it via Homebrew:

brew install mozjpeg

FreeBSD

pkg install mozjpeg
git clone https://github.com/danielgtaylor/jpeg-archive.git
cd jpeg-archive/
gmake
sudo gmake install

Windows

The Makefile should work with MinGW/Cygwin/etc and standard GCC. Patches welcome.

To get everything you need to build, install these:

Run Github for windows. In the settings, set Git Bash as the shell. Open Git Shell from the start menu.

# Update PATH to include MinGW/NASM bin folder, location on your system may vary
export PATH=/c/mingw/mingw32/bin:/c/Program\ Files \(x68\)/nasm:$PATH

# Build mozjpeg or download https://www.dropbox.com/s/98jppfgds2xjblu/libjpeg.a
git clone https://github.com/mozilla/mozjpeg.git
cd mozjpeg
cmake -G "MSYS Makefiles" -D CMAKE_C_COMPILER=gcc.exe -D CMAKE_MAKE_PROGRAM=mingw32-make.exe  -D WITH_JPEG8=1
mingw32-make
cd ..

# Build jpeg-archive
git clone https://github.com/danielgtaylor/jpeg-archive
cd jpeg-archive
CC=gcc mingw32-make

JPEG-Archive should now be built.

Compiling (Linux and Mac OS X)

The Makefile should work as-is on Ubuntu and Mac OS X. Other platforms may need to set the location of libjpeg.a or make other tweaks.

make

Installation

Install the binaries into /usr/local/bin:

sudo make install

Links / Alternatives

License

All are released under an MIT license.

http://dgt.mit-license.org/

More Repositories

1

aglio

An API Blueprint renderer with theme support that outputs static HTML
CoffeeScript
4,746
star
2

huma

Huma REST/HTTP API Framework for Golang with OpenAPI 3.1
Go
1,895
star
3

python-betterproto

Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC
Python
1,513
star
4

apisprout

Lightweight, blazing fast, cross-platform OpenAPI 3 mock server with validation
Go
639
star
5

restish

Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
Go
497
star
6

qtfaststart

Quicktime atom positioning in Python for fast streaming
Python
450
star
7

nesh

An enhanced, extensible interactive shell for Node.js and CoffeeScript
CoffeeScript
287
star
8

openapi-cli-generator

Generate a CLI from an OpenAPI 3 specification
Go
154
star
9

arista

Arista Transcoder
Python
120
star
10

ladon

A small, simple cross-platform utility to process many files in parallel.
JavaScript
81
star
11

braintree_django

Braintree Django Module
Python
52
star
12

atom-api-blueprint-preview

Live preview API Blueprint in Atom
CoffeeScript
45
star
13

html5-space-fighter

HTML5 Space Fighter Game
JavaScript
30
star
14

apilint

Extensible REST API linter utility
JavaScript
27
star
15

malt.io

Malt.io free community for brewers
Python
26
star
16

qtrotate

Tools for handling rotated Quicktime/MP4 files
Python
26
star
17

qtfaststart.js

Javascript version of qt-faststart
JavaScript
21
star
18

guid-tool-web

GUID conversion tool website
Python
18
star
19

atom-language-api-blueprint

API Blueprint and MSON grammars for the Atom.io text editor.
CoffeeScript
14
star
20

django-ccss

Django CleverCSS
Python
13
star
21

tech-talk

Markdown slideshows with a built-in terminal that just works
JavaScript
13
star
22

mexpr

Micro expression parser library for Go
Go
12
star
23

node-desktop-uploader

Recursively watch directories and upload new/updated files
CoffeeScript
11
star
24

shorthand

Structured data & CLI shorthand syntax for Go
Go
10
star
25

atom-monokai-extended

Extended Monokai theme for the Atom text editor
CSS
9
star
26

unistyle

โ„ฑ๐’ถ๐“ƒ๐’ธ๐“Ž ๐˜๐—ฒ๐˜…๐˜ ๐˜ด๐˜ต๐˜บ๐˜ญ๐˜ฆ๐˜ด ๐”ฃ๐”ฌ๐”ฏ Gฬณoฬณlฬณaฬณnฬณgฬณ in a compact, zero dependency library.
Go
7
star
27

guid-tool

A tool to convert between various forms of GUID
Python
7
star
28

ffmpeg

FFmpeg + patches
C
7
star
29

eidolon

Generate JSON or JSON Schema from Refract & MSON data structures
CoffeeScript
6
star
30

paodate

Simpler Python date handling
Python
5
star
31

mateo

A simple API description interface library
JavaScript
5
star
32

sdt

Structured Data Templates
Go
4
star
33

peasant

An opinionated Node.js ES6 module lint/build/test/coverage helper
JavaScript
3
star
34

dotfiles

My public dotfiles to help bootstrap a new machine
Shell
3
star
35

polaris

Lightweight backend utilities for static websites
CoffeeScript
3
star
36

apiscrub

OpenAPI Scrubber
Python
3
star
37

bible-ref

Utilities for handling Bible references
CoffeeScript
2
star
38

homebrew-restish

Homebrew Tap for Restish https://rest.sh/
Ruby
2
star
39

casing

An intelligent casing conversion library for Go
Go
2
star
40

injectobot

Developer-friendly programmable IRC bot
CoffeeScript
2
star
41

huma-build

Docker build utility for Huma REST OpenAPI projects
Go
2
star
42

rhs-color

R.H.S. color conversion utilities
JavaScript
2
star
43

apibin

Example API with modern features
Go
2
star
44

nesh-hello

A simple example plugin for Nesh, the Node.js enhanced shell.
JavaScript
1
star
45

arista-website

Arista Transcoder Website
JavaScript
1
star
46

gaaflora-website

http://www.gaaflora.com/
HTML
1
star
47

vscode-sdt

Visual Studio Code support for Structured Data Templates
JavaScript
1
star