#!/usr/bin/perl -wuse strict;my $soi = "\xFF\xD8";my $buffer;my $byte;my $index = 0;my $filename = $ARGV[ 0 ] || 'image-';binmode STDIN;die "cannot read ($!)" unless read( STDIN, $buffer, 2 );die "does not being with JPEG SOI marker" unless $buffer eq $soi;$byte = substr( $buffer, 0, 1 );FILE: while (1) { open IMAGE, '>', sprintf( "%s%03i.jpg", $filename, ++$index ) || die "cannot open new file ($!)"; binmode IMAGE; do { print IMAGE $byte; $buffer = substr( $buffer, 1, 1 ); last FILE unless read( STDIN, $byte, 1 ); $buffer .= $byte; $byte = substr( $buffer, 0, 1 ); } while ($buffer ne $soi); close IMAGE;}
It isn't exactly write, but seems to work somewhat in my test cases.find sd -iname '*.jpg -exec mv -v {} ~/Documents/My\ Pictures/051002 but, of course, I forgot to create that directory in advance! Looks like the pictures from my 35th birthday party are gone forever... :: sniff ::
dd if=/dev/sda1 of=image.img bs=512
java jpegExtract image.img
posted by slater at 7:47 AM on October 2, 2005