def generate_img_id(profile, ext=None, label=None, tmp=False):
if ext and not ext.startswith('<STR_LIT:.>'):<EOL><INDENT>ext = '<STR_LIT:.>' + ext<EOL><DEDENT>if label:<EOL><INDENT>label = re.sub(r'<STR_LIT>', '<STR_LIT>', label, flags=re.I)<EOL>label = re.sub(r'<STR_LIT>', '<STR_LIT:_>', label)<EOL>label = label[:<NUM_LIT>]<EOL><DEDENT>return '<STR_LIT>'.format(<EOL>profile=profile,<EOL>tmp=(dju_settings.DJU_IMG_UPLOAD_TMP_PREFIX if tmp else '<STR_LIT>'),<EOL>dtstr=datetime_to_dtstr(),<EOL>rand=get_random_string(<NUM_LIT:4>, '<STR_LIT>'),<EOL>label=(('<STR_LIT:_>' + label) if label else '<STR_LIT>'),<EOL>ext=(ext or '<STR_LIT>'),<EOL>)<EOL>
Generates img_id.