#jpeg #raw #extract #camera #filesystem

app rawtojpg

A very fast embedded JPEG extractor from RAW files

9 unstable releases (3 breaking)

0.6.0 Jan 23, 2025
0.5.3 Jun 21, 2024
0.5.2 May 25, 2024
0.4.0 May 14, 2024
0.3.2 May 9, 2024

#558 in Command line utilities

Download history 6/week @ 2024-12-10 117/week @ 2025-01-21 2/week @ 2025-01-28 9/week @ 2025-02-04

128 downloads per month

MIT license

15KB
232 lines

rawtojpg

rawtojpg provides a much faster way to extract embedded JPEGs from RAW files than exiftool's -JpgFromRaw. In a directory with 4000 files, rawtojpg extracts JPEGs about 15 times faster than exiftool:

% rm -rf ~/rtj && mkdir -p ~/rtj/{rawtojpg, exiftool}
% sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches'
% \time -v rawtojpg /mnt/sdcard/DCIM/101MSDCF ~/rtj/rawtojpg >/dev/null
    User time (seconds): 2.18
    System time (seconds): 20.99
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:29.72
    File system inputs: 22956551
    File system outputs: 22855504


% sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches'
% \time -v exiftool -b -JpgFromRaw -ext arw -r /mnt/sdcard/DCIM/101MSDCF -w ~/rtj/exiftool/%f.jpg >/dev/null
    User time (seconds): 113.21
    System time (seconds): 58.15
    Elapsed (wall clock) time (h:mm:ss or m:ss): 7:52.87
    File system inputs: 316175244
    File system outputs: 22864400

The total size of the output JPEGs is 11.5GiB, so in terms of throughput, rawtojpg does ~386MiB/s, and exiftool does ~24MiB/s.

The key reason rawtojpg is so much faster is because it very carefully avoids overreading into the entire RAW file. exiftool does not do that and suffers quite greatly in (useful) throughput as a result. This is achieved through judicious use of madvise.

Other than that, rawtojpg also processes multiple files concurrently, which can help a lot on faster devices like CFexpress cards.

Dependencies

~6–15MB
~169K SLoC