full_tile_widths can be 0 for items with many parts
This commit is contained in:
parent
0f0f5f42d8
commit
400162e400
1 changed files with 16 additions and 14 deletions
|
@ -9,6 +9,16 @@ import re
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from ox.utils import json
|
from ox.utils import json
|
||||||
|
|
||||||
|
__all__ = ['join_tiles', 'split_tiles']
|
||||||
|
|
||||||
|
def divide(num, by):
|
||||||
|
# divide(100, 3) -> [33, 33, 34]
|
||||||
|
arr = []
|
||||||
|
div = int(num / by)
|
||||||
|
mod = num % by
|
||||||
|
for i in range(int(by)):
|
||||||
|
arr.append(div + (i > by - 1 - mod))
|
||||||
|
return arr
|
||||||
|
|
||||||
def join_tiles(source_paths, durations, target_path):
|
def join_tiles(source_paths, durations, target_path):
|
||||||
'''
|
'''
|
||||||
|
@ -17,15 +27,6 @@ def join_tiles(source_paths, durations, target_path):
|
||||||
be written to target_path.
|
be written to target_path.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def divide(num, by):
|
|
||||||
# divide(100, 3) -> [33, 33, 34]
|
|
||||||
arr = []
|
|
||||||
div = int(num / by)
|
|
||||||
mod = num % by
|
|
||||||
for i in range(int(by)):
|
|
||||||
arr.append(div + (i > by - 1 - mod))
|
|
||||||
return arr
|
|
||||||
|
|
||||||
def get_file_info(file_name):
|
def get_file_info(file_name):
|
||||||
for mode in modes:
|
for mode in modes:
|
||||||
if re.match('^timeline' + mode + '64p\d+\.jpg', file_name):
|
if re.match('^timeline' + mode + '64p\d+\.jpg', file_name):
|
||||||
|
@ -84,11 +85,12 @@ def join_tiles(source_paths, durations, target_path):
|
||||||
#print(image_file)
|
#print(image_file)
|
||||||
if mode == full_tile_mode:
|
if mode == full_tile_mode:
|
||||||
# render full tile
|
# render full tile
|
||||||
resized = data['target_images']['large'].resize((
|
if data['full_tile_widths'][0]:
|
||||||
data['full_tile_widths'][0], large_tile_h
|
resized = data['target_images']['large'].resize((
|
||||||
), Image.ANTIALIAS)
|
data['full_tile_widths'][0], large_tile_h
|
||||||
data['target_images']['full'].paste(resized, (data['full_tile_offset'], 0))
|
), Image.ANTIALIAS)
|
||||||
data['full_tile_offset'] += data['full_tile_widths'][0]
|
data['target_images']['full'].paste(resized, (data['full_tile_offset'], 0))
|
||||||
|
data['full_tile_offset'] += data['full_tile_widths'][0]
|
||||||
data['full_tile_widths'] = data['full_tile_widths'][1:]
|
data['full_tile_widths'] = data['full_tile_widths'][1:]
|
||||||
large_tile_i += 1
|
large_tile_i += 1
|
||||||
# open next large tile
|
# open next large tile
|
||||||
|
|
Loading…
Reference in a new issue