2 # This script converts a raster format picture into an ascii representation
12 os.execvp("convert", ["convert", sys.argv[1], "temporary_filename_that_is_long.gif"])
13 print "Could not run convert"
17 os.system("identify temporary_filename_that_is_long.gif > temp.dim")
19 fp = open("temp.dim", "r")
21 lines = string.split(line,' ')
22 dims = string.split(lines[1],'x')
23 xsize = float(dims[0])
24 ysize = float(string.split(dims[1],'+')[0])
26 aspect_ratio = xsize / ysize
29 resulting_x = int(sys.argv[2])
32 resulting_y = int(resulting_x / aspect_ratio)
34 os.system("echo s | gifscii temporary_filename_that_is_long.gif %d %d" % (resulting_x, resulting_y))
36 os.system("tail +3 temporary_filename_that_is_long.asc > temporary_filename_that_is_long2.asc")
40 os.execvp("mv", ["mv", "temporary_filename_that_is_long2.asc", os.path.splitext(sys.argv[1])[0] + ".asc"])
41 print "Could not rename file"
45 os.system("rm temporary_filename_that_is_long.gif temporary_filename_that_is_long.asc")