You can do this pretty easily with perl using the GD module or convert the images to
a text format like PPM and use an text langage to parse it (all *nix tools/formats).
I have written a program that takes a PPM file and generate the G-gode for the
image (no write ups, and it has no error handling whatsoever so it is not
very useful for other people). Unfortunately, I do not know the syntax of a DXF file to
generate the output. Except for the DXF output part, this is a pretty easy process.