Works for disk images too.
More to say, it's a free & open source (GPL v2+) cross-platform (Linux, *BSD, Apple Mac OS X, Oracle / Sun Solaris, MS-DOS, MS Windows) software.
Presently, in Debian-based Linux distros, TestDisk & PhotoRec have been packaged into a single
testdisk
package, so you can install both tools at once:# apt-get install testdisk