def random_image(field):

    color1 = random_rgb()
    color2 = random_rgb()
    color3 = random_rgb()
    color4 = random_rgb()
    size = (random.randint(300, 900), random.randint(300, 900))

    im = Image.new("RGB", size)  # create the image
    draw = ImageDraw.Draw(im)    # create a drawing object that is
    draw.rectangle(
        [(0, 0), ((size[0] / 2), (size[1] / 2))],
        fill=color1
    )
    draw.rectangle(
        [((size[0] / 2), 0), ((size[1] / 2), size[0])],
        fill=color2
    )
    draw.rectangle(
        [(0, (size[1] / 2)), ((size[0] / 2), size[1])],
        fill=color3
    )
    draw.rectangle(
        [((size[0] / 2), (size[1] / 2)), (size[0], size[1])],
        fill=color4
    )

    filename = "%s.png" % uuid.uuid4().hex[:10]
    filename = field.generate_filename(None, filename)
    storage = DefaultStorage()
    full_path = storage.path(filename)
    directory = os.path.dirname(full_path)

    try:
        os.makedirs(directory)
    except __HOLE__ as e:
        if e.errno != errno.EEXIST:
            raise

    filehandle = storage.open(filename, mode="w")
    im.save(filehandle, "PNG")

    filehandle.close()

    return filename  # and we"re done!
dataset/ETHPy150Open ccollins/milkman/milkman/generators.py/random_image