def is_valid_image(self, raw_data):
with NamedTemporaryFile(mode='<STR_LIT:wb>') as fp:<EOL><INDENT>fp.write(raw_data)<EOL>fp.flush()<EOL>args = settings.THUMBNAIL_IDENTIFY.split('<STR_LIT:U+0020>')<EOL>args.append(fp.name + '<STR_LIT>')<EOL>p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)<EOL>retcode = p.wait()<EOL><DEDENT>return retcode == <NUM_LIT:0><EOL>
This is not very good for imagemagick because it will say anything is
valid that it can use as input.