Better cope with non-standard max values.

Deal with images stored in a variable instead of a file.
