I've got a formatted FAT32 memory card. It contains JPEG photos. I know this because I wrote a little tool to recover them, and managed to get files around 14000 to 17000 bytes in size that pcmanfm can generate thumbnails for.

However, my operating system does not know that the memory card contains JPEG photos, because the camera was used to format it.

So far, I've tried several programs and the best I've got is a picture of a drain that looks suspiciously like the first file I've got a partial recovery of; I expect this is because the file was deleted before the formatting occurred. I've given up on such recovery programs.

Now I'd like to know whether there's a tool that can allow me to manually piece together valid JPEG files from the logical data blocks in a FAT32 disc image. Does such a tool exist?

(In case you're wondering, here's a copy of the program that almost worked:)

import itertools
import time
name_prefix = 'recovered/' + str(time.time()) + '#'
filename = (name_prefix + str(n) + '.jpg' for n in itertools.count())

with open("carddump.img", "rb") as f:
    partial_image_files = []
    found_special_marker = False
    byte = "rb"  # doesn't matter what it is
    while byte != b'':
        byte = f.read(1)
        if byte == b'\xff':
            found_special_marker = True
        elif found_special_marker:
            if byte == b'\xd8':
                partial_image_files.append(open(next(filename), "wb"))
            elif byte == b'\xd9':
                for file in partial_image_files:
                del partial_image_files[:]
            found_special_marker = False
        for file in partial_image_files:

(Every 3nth file had a thumbnail. 3n+1 was slightly smaller than 3n, and 3n+2 was a few MiB.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.