def avatarGen(value): avatar = Avatar(rows=10, columns=10) image_byte_array = avatar.get_image(string=value, width=50, height=50, pad=10) avatar.save(image_byte_array=image_byte_array, save_location='static/img/' + value + '.png') return 'static/img/' + value + '.png'
def main(): # Example usage avatar = Avatar(rows=10, columns=10) image_byte_array = avatar.get_image(string='john_smith_2008', width=400, height=400, pad=10) return avatar.save(image_byte_array=image_byte_array, save_location='example.png')
def generate_random_avatar(filename=None, n=10): if not filename: raise ValueError( 'Please set a file path where to save generated avatar') st = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(n)) avatar = Avatar(rows=13, columns=13) image_byte_array = avatar.get_image(string=st, width=89, height=89, pad=10) return avatar.save(image_byte_array=image_byte_array, save_location=filename)
def avatarGen(value): avatar = Avatar(rows=10, columns=10) image_byte_array = avatar.get_image(string=value, width=50, height=50, pad=10) avatar.save(image_byte_array=image_byte_array, save_location='static/img/'+value+'.png') return 'static/img/'+value+'.png'
def main(): # Example usage avatar = Avatar(rows=10, columns=10) image_byte_array = avatar.get_image(string="john_smith_2008", width=400, height=400, pad=10) return avatar.save(image_byte_array=image_byte_array, save_location="example.png")