This is some software to check for JPEGs where the embedded thumbnail
differs in an interesting way from the main image. It is lab-quality
software, so don't rely on it. It is written by Stevon J. Murdoch with
contributions by Maximillian Dornseif. Contact us with any questions.

See config.py to change stuff to your needs. You might need to use
convert.py to convert wget -m output or something similar to something
we can process. Comandline options have changed somewhat since this
code is written.

check_images.py
===============

This program recursively descends from a directory, and checks each
file, ending in ".jpeg" or ".jpg" (non case-sensitive), for a
thumbnail which is different from the main image. It takes two command
line parameters. The first is INPUTDIR, the directory from which to
start the search. The second is OUTPUTFILE which is where the results
will be written, this file will be overwritten by the program. Minimal
logging is also sent to "log.txt", which is also overwritten. If the
"deleted_files" variable is set to true, then non-JPEG files and JPEG
files without thumbnails are deleted. The filenames of files deleted
in this way are appended to "deleted_files.txt", one per line.

The OUTPUTFILE format is as follows. A line '"filename" "ratio"
"rms"', then for each image a line consisting of an index, the path,
the ratio difference and the RMS difference, separated by spaces. This
file is suitable for import into GNU R.

A temporary file is written in /tmp/thumb_check.jpg (this is a
security problem and should be fixed before the program is
distributed).

The program jhead is used to extract the thumbnails.

Example invocation:
 $ ./check_images.py images/ results.data

filter.R
========

This R script selects "interesting" images for further processing. It
expects input in the file "results.data" in the format output by
check_images.py and puts the output in "flagged.data" in the same
format. If "flagged.data" already exists, it is overwritten.

Example invocation:
 $ R --no-save < filter.R 

show_images.py
==============

This program displays the thumbnail and full image together for
comparison. It takes four arguments which are as follows. INPUTFILE
SKIPFILE OUTPUTDIR OUTPUTFILE. The first is INPUTFILE, listing the
files to be processed. It is of the format produced by filter.R. The
second is the SKIPFILE, which is of the same format and lists files to
be ignored. The third, OUTPUTDIR, is where the images will be
created. This directory must be empty. The fourth is OUTPUTFILE, which
lists the created files. For each line the first number is the
filename which the new file is created as, the second item is the
original filename.

A temporary file is written in /tmp/thumb_show.jpg (this is a
security problem and should be fixed before the program is
distributed).

The program jhead is used to extract the thumbnails.

Example invocation:
 $ rm skip.data; touch skip.data
 $ mv output output.old; mkdir output
 $ ./show_images flagged.data skip.data output/ output.data 

jhead.patch
===========

This patch prevents jhead from producing output in the two common
cases, when a thumbnail can be found and when a thumbnail is missing
from a valid JPEG file.