data = list(img.getdata())
for y in range(img.size[1]):
i = (img.size[1]-1-y)*img.size[0]
- result += escape("".join(["".join([chr(v) for v in p]) for p in data[i:i+img.size[0]]]))
+ if fmt=="LUMINANCE" or fmt=="SLUMINANCE":
+ result += escape("".join([chr(v) for v in data[i:i+img.size[0]]]))
+ else:
+ result += escape("".join(["".join([chr(v) for v in p]) for p in data[i:i+img.size[0]]]))
result += "\";\n"
return result