You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
582 B
Python
28 lines
582 B
Python
# Copyright (C) 2022 CVAT.ai Corporation
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
from io import BytesIO
|
|
from typing import List
|
|
|
|
from PIL import Image
|
|
|
|
|
|
def generate_image_file(filename="image.png", size=(50, 50), color=(0, 0, 0)):
|
|
f = BytesIO()
|
|
image = Image.new("RGB", size=size, color=color)
|
|
image.save(f, "jpeg")
|
|
f.name = filename
|
|
f.seek(0)
|
|
|
|
return f
|
|
|
|
|
|
def generate_image_files(count) -> List[BytesIO]:
|
|
images = []
|
|
for i in range(count):
|
|
image = generate_image_file(f"{i}.jpeg", color=(i, i, i))
|
|
images.append(image)
|
|
|
|
return images
|