Move checkerboard_image to imagetools.
This commit is contained in:
parent
0c51201901
commit
7c1b6b293d
1 changed files with 1 additions and 25 deletions
|
@ -124,30 +124,6 @@ def album_photos_as_filename_map(
|
||||||
|
|
||||||
return arcnames
|
return arcnames
|
||||||
|
|
||||||
def checkerboard_image(color_1, color_2, image_size, checker_size) -> PIL.Image:
|
|
||||||
'''
|
|
||||||
Generate a PIL Image with a checkerboard pattern.
|
|
||||||
|
|
||||||
color_1:
|
|
||||||
The color starting in the top left. Either RGB tuple or a string
|
|
||||||
that PIL understands.
|
|
||||||
color_2:
|
|
||||||
The alternate color
|
|
||||||
image_size:
|
|
||||||
Tuple of two integers, the image size in pixels.
|
|
||||||
checker_size:
|
|
||||||
Tuple of two integers, the size of each checker in pixels.
|
|
||||||
'''
|
|
||||||
image = PIL.Image.new('RGB', image_size, color_1)
|
|
||||||
checker = PIL.Image.new('RGB', (checker_size, checker_size), color_2)
|
|
||||||
offset = True
|
|
||||||
for y in range(0, image_size[1], checker_size):
|
|
||||||
for x in range(0, image_size[0], checker_size * 2):
|
|
||||||
x += offset * checker_size
|
|
||||||
image.paste(checker, (x, y))
|
|
||||||
offset = not offset
|
|
||||||
return image
|
|
||||||
|
|
||||||
def decollide_names(things, namer):
|
def decollide_names(things, namer):
|
||||||
'''
|
'''
|
||||||
When generating zip files, or otherwise exporting photos to disk, it is
|
When generating zip files, or otherwise exporting photos to disk, it is
|
||||||
|
@ -221,7 +197,7 @@ def generate_image_thumbnail(filepath, width, height) -> PIL.Image:
|
||||||
image = image.resize((new_width, new_height))
|
image = image.resize((new_width, new_height))
|
||||||
|
|
||||||
if image.mode == 'RGBA':
|
if image.mode == 'RGBA':
|
||||||
background = checkerboard_image(
|
background = imagetools.checkerboard_image(
|
||||||
color_1=(256, 256, 256),
|
color_1=(256, 256, 256),
|
||||||
color_2=(128, 128, 128),
|
color_2=(128, 128, 128),
|
||||||
image_size=image.size,
|
image_size=image.size,
|
||||||
|
|
Loading…
Reference in a new issue