Image.ANTIALIAS->Image.LANCZOS
This commit is contained in:
parent
eee51e672c
commit
cbaeffde68
10 changed files with 26 additions and 25 deletions
|
@ -459,7 +459,7 @@ def resize_image(image_source, image_output, width=None, size=None):
|
|||
height = max(height, 1)
|
||||
|
||||
if width < source_width:
|
||||
resize_method = Image.ANTIALIAS
|
||||
resize_method = Image.LANCZOS
|
||||
else:
|
||||
resize_method = Image.BICUBIC
|
||||
output = source.resize((width, height), resize_method)
|
||||
|
@ -605,7 +605,7 @@ def timeline_strip(item, cuts, info, prefix):
|
|||
print(frame, 'cut', c, 'frame', s, frame, 'width', widths[s], box)
|
||||
# FIXME: why does this have to be frame+1?
|
||||
frame_image = Image.open(item.frame((frame+1)/fps))
|
||||
frame_image = frame_image.crop(box).resize((widths[s], timeline_height), Image.ANTIALIAS)
|
||||
frame_image = frame_image.crop(box).resize((widths[s], timeline_height), Image.LANCZOS)
|
||||
for x_ in range(widths[s]):
|
||||
line_image.append(frame_image.crop((x_, 0, x_ + 1, timeline_height)))
|
||||
frame += widths[s]
|
||||
|
|
|
@ -161,7 +161,7 @@ class FulltextMixin:
|
|||
img = Image.alpha_composite(img, overlay)
|
||||
img = img.convert("RGB")
|
||||
aspect = img.size[0] / img.size[1]
|
||||
resize_method = Image.ANTIALIAS
|
||||
resize_method = Image.LANCZOS
|
||||
if img.size[0] >= img.size[1]:
|
||||
width = size
|
||||
height = int(size / aspect)
|
||||
|
|
|
@ -71,7 +71,7 @@ def join_tiles(source_paths, durations, target_path):
|
|||
if not w or large_tile_i < large_tile_n - 1:
|
||||
w = 60
|
||||
data['target_images']['large'] = data['target_images']['large'].resize(
|
||||
(w, small_tile_h), Image.ANTIALIAS
|
||||
(w, small_tile_h), Image.LANCZOS
|
||||
)
|
||||
if data['target_images']['small']:
|
||||
data['target_images']['small'].paste(
|
||||
|
@ -90,7 +90,7 @@ def join_tiles(source_paths, durations, target_path):
|
|||
if data['full_tile_widths'][0]:
|
||||
resized = data['target_images']['large'].resize((
|
||||
data['full_tile_widths'][0], large_tile_h
|
||||
), Image.ANTIALIAS)
|
||||
), Image.LANCZOS)
|
||||
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:]
|
||||
|
@ -196,7 +196,7 @@ def join_tiles(source_paths, durations, target_path):
|
|||
#print(image_file)
|
||||
image_file = '%stimeline%s%dp.jpg' % (target_path, full_tile_mode, small_tile_h)
|
||||
data['target_images']['full'].resize(
|
||||
(full_tile_w, small_tile_h), Image.ANTIALIAS
|
||||
(full_tile_w, small_tile_h), Image.LANCZOS
|
||||
).save(image_file)
|
||||
#print(image_file)
|
||||
|
||||
|
|
|
@ -20,3 +20,4 @@ elasticsearch<8
|
|||
future
|
||||
pytz
|
||||
pypdfium2
|
||||
Pillow>=10
|
||||
|
|
|
@ -20,11 +20,11 @@ def render_icon(frame, timeline, icon):
|
|||
frame_image = Image.open(frame) if frame else Image.new('RGB', (1024, 768), (0, 0, 0))
|
||||
frame_image_ratio = frame_image.size[0] / frame_image.size[1]
|
||||
if frame_ratio < frame_image_ratio:
|
||||
frame_image = frame_image.resize((int(frame_height * frame_image_ratio), frame_height), Image.ANTIALIAS)
|
||||
frame_image = frame_image.resize((int(frame_height * frame_image_ratio), frame_height), Image.LANCZOS)
|
||||
left = int((frame_image.size[0] - frame_width) / 2)
|
||||
frame_image = frame_image.crop((left, 0, left + frame_width, frame_height))
|
||||
else:
|
||||
frame_image = frame_image.resize((frame_width, int(frame_width / frame_image_ratio)), Image.ANTIALIAS)
|
||||
frame_image = frame_image.resize((frame_width, int(frame_width / frame_image_ratio)), Image.LANCZOS)
|
||||
top = int((frame_image.size[1] - frame_height) / 2)
|
||||
frame_image = frame_image.crop((0, top, frame_width, top + frame_height))
|
||||
icon_image.paste(frame_image, (0, 0))
|
||||
|
@ -36,7 +36,7 @@ def render_icon(frame, timeline, icon):
|
|||
mask_image = Image.open(os.path.join(static_root, 'iconTimelineOuterMask.png'))
|
||||
icon_image.paste(timeline_image, (timeline_left - 4, timeline_top - 4), mask=mask_image)
|
||||
timeline_image = Image.open(timeline) if timeline else Image.new('RGB', (timeline_width, timeline_height), (0, 0, 0))
|
||||
timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.ANTIALIAS)
|
||||
timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.LANCZOS)
|
||||
mask_image = Image.open(os.path.join(static_root, 'iconTimelineInnerMask.png'))
|
||||
icon_image.paste(timeline_image, (timeline_left, timeline_top), mask=mask_image)
|
||||
# we're using jpegs with border-radius
|
||||
|
|
|
@ -24,11 +24,11 @@ def render_list_icon(frames, icon):
|
|||
frame_image_ratio = frame_image.size[0] / frame_image.size[1]
|
||||
frame_width_ = frame_width + (1 if i % 2 == 1 else 0)
|
||||
if frame_ratio < frame_image_ratio:
|
||||
frame_image = frame_image.resize((int(frame_height * frame_image_ratio), frame_height), Image.ANTIALIAS)
|
||||
frame_image = frame_image.resize((int(frame_height * frame_image_ratio), frame_height), Image.LANCZOS)
|
||||
left = int((frame_image.size[0] - frame_width_) / 2)
|
||||
frame_image = frame_image.crop((left, 0, left + frame_width_, frame_height))
|
||||
else:
|
||||
frame_image = frame_image.resize((frame_width_, int(frame_width_ / frame_image_ratio)), Image.ANTIALIAS)
|
||||
frame_image = frame_image.resize((frame_width_, int(frame_width_ / frame_image_ratio)), Image.LANCZOS)
|
||||
top = int((frame_image.size[1] - frame_height) / 2)
|
||||
frame_image = frame_image.crop((0, top, frame_width_, top + frame_height))
|
||||
icon_image.paste(frame_image, (i % 2 * frame_width + (1 if i % 2 == 2 else 0),
|
||||
|
|
|
@ -64,11 +64,11 @@ def render_poster(data, poster):
|
|||
frame_image = Image.open(frame)
|
||||
frame_image_ratio = frame_image.size[0] / frame_image.size[1]
|
||||
if frame_ratio < frame_image_ratio:
|
||||
frame_image = frame_image.resize((int(frame_size[1] * frame_image_ratio), frame_size[1]), Image.ANTIALIAS)
|
||||
frame_image = frame_image.resize((int(frame_size[1] * frame_image_ratio), frame_size[1]), Image.LANCZOS)
|
||||
left = int((frame_image.size[0] - frame_size[0]) / 2)
|
||||
frame_image = frame_image.crop((left, 0, left + frame_size[0], frame_size[1]))
|
||||
else:
|
||||
frame_image = frame_image.resize((frame_size[0], int(frame_size[0] / frame_image_ratio)), Image.ANTIALIAS)
|
||||
frame_image = frame_image.resize((frame_size[0], int(frame_size[0] / frame_image_ratio)), Image.LANCZOS)
|
||||
top = int((frame_image.size[1] - frame_size[1]) / 2)
|
||||
frame_image = frame_image.crop((0, top, frame_size[0], top + frame_size[1]))
|
||||
poster_image.paste(frame_image, (0, 0))
|
||||
|
@ -77,7 +77,7 @@ def render_poster(data, poster):
|
|||
|
||||
# logo
|
||||
logo_image = Image.open(os.path.join(static_root, 'logo.0xdb.png'))
|
||||
logo_image = logo_image.resize(logo_size, Image.ANTIALIAS)
|
||||
logo_image = logo_image.resize(logo_size, Image.LANCZOS)
|
||||
for y in range(logo_size[1]):
|
||||
for x in range(logo_size[0]):
|
||||
poster_color = poster_image.getpixel((margin + x, margin + y))
|
||||
|
@ -95,11 +95,11 @@ def render_poster(data, poster):
|
|||
if small_frame_image:
|
||||
small_frame_image_ratio = small_frame_image.size[0] / small_frame_image.size[1]
|
||||
if small_frame_ratio < small_frame_image_ratio:
|
||||
small_frame_image = small_frame_image.resize((int(small_frame_size[1] * small_frame_image_ratio), small_frame_size[1]), Image.ANTIALIAS)
|
||||
small_frame_image = small_frame_image.resize((int(small_frame_size[1] * small_frame_image_ratio), small_frame_size[1]), Image.LANCZOS)
|
||||
left = int((small_frame_image.size[0] - small_frame_size[0]) / 2)
|
||||
small_frame_image = small_frame_image.crop((left, 0, left + small_frame_size[0], small_frame_size[1]))
|
||||
else:
|
||||
small_frame_image = small_frame_image.resize((small_frame_size[0], int(small_frame_size[0] / small_frame_image_ratio)), Image.ANTIALIAS)
|
||||
small_frame_image = small_frame_image.resize((small_frame_size[0], int(small_frame_size[0] / small_frame_image_ratio)), Image.LANCZOS)
|
||||
top = int((small_frame_image.size[1] - small_frame_size[1]) / 2)
|
||||
small_frame_image = small_frame_image.crop((0, top, small_frame_size[0], top + small_frame_size[1]))
|
||||
poster_image.paste(small_frame_image, (i * small_frame_size[0], frame_size[1]))
|
||||
|
@ -189,7 +189,7 @@ def render_poster(data, poster):
|
|||
# timeline
|
||||
if timeline:
|
||||
timeline_image = Image.open(timeline)
|
||||
timeline_image = timeline_image.resize(timeline_size, Image.ANTIALIAS)
|
||||
timeline_image = timeline_image.resize(timeline_size, Image.LANCZOS)
|
||||
poster_image.paste(timeline_image, (0, poster_size[1] - timeline_size[1]))
|
||||
else:
|
||||
draw.rectangle(((0, poster_size[1] - timeline_size[1]), poster_size), fill=image_color)
|
||||
|
|
|
@ -160,7 +160,7 @@ def render_poster(data, poster):
|
|||
if frame_ratio < frame_image_ratio:
|
||||
frame_image = frame_image.resize(
|
||||
(int(frame_height * frame_image_ratio), frame_height),
|
||||
Image.ANTIALIAS
|
||||
Image.LANCZOS
|
||||
)
|
||||
left = int((frame_image.size[0] - poster_width) / 2)
|
||||
frame_image = frame_image.crop(
|
||||
|
@ -169,7 +169,7 @@ def render_poster(data, poster):
|
|||
else:
|
||||
frame_image = frame_image.resize(
|
||||
(poster_width, int(poster_width / frame_image_ratio)),
|
||||
Image.ANTIALIAS
|
||||
Image.LANCZOS
|
||||
)
|
||||
top = int((frame_image.size[1] - frame_height) / 2)
|
||||
frame_image = frame_image.crop(
|
||||
|
@ -187,7 +187,7 @@ def render_poster(data, poster):
|
|||
timeline_image = Image.open(timeline)
|
||||
timeline_image = timeline_image.resize(
|
||||
(poster_width, timeline_height),
|
||||
Image.ANTIALIAS
|
||||
Image.LANCZOS
|
||||
)
|
||||
poster_image.paste(timeline_image, (0, poster_height - timeline_height))
|
||||
else:
|
||||
|
|
|
@ -33,7 +33,7 @@ def render_poster(data, poster):
|
|||
timeline_lines = 16
|
||||
if timeline:
|
||||
timeline_image = Image.open(timeline)
|
||||
timeline_image = timeline_image.resize((10240, timeline_height), Image.ANTIALIAS)
|
||||
timeline_image = timeline_image.resize((10240, timeline_height), Image.LANCZOS)
|
||||
for i in range(timeline_lines):
|
||||
line_image = timeline_image.crop((i * poster_width, 0, (i + 1) * poster_width, 64))
|
||||
poster_image.paste(line_image, (0, i * timeline_height))
|
||||
|
|
|
@ -62,11 +62,11 @@ def render_poster(data, poster):
|
|||
frame_image = Image.open(frame)
|
||||
frame_image_ratio = frame_image.size[0] / frame_image.size[1]
|
||||
if frame_ratio < frame_image_ratio:
|
||||
frame_image = frame_image.resize((int(frame_height * frame_image_ratio), frame_height), Image.ANTIALIAS)
|
||||
frame_image = frame_image.resize((int(frame_height * frame_image_ratio), frame_height), Image.LANCZOS)
|
||||
left = int((frame_image.size[0] - frame_width) / 2)
|
||||
frame_image = frame_image.crop((left, 0, left + frame_width, frame_height))
|
||||
else:
|
||||
frame_image = frame_image.resize((frame_width, int(frame_width / frame_image_ratio)), Image.ANTIALIAS)
|
||||
frame_image = frame_image.resize((frame_width, int(frame_width / frame_image_ratio)), Image.LANCZOS)
|
||||
top = int((frame_image.size[1] - frame_height) / 2)
|
||||
frame_image = frame_image.crop((0, top, frame_width, top + frame_height))
|
||||
poster_image.paste(frame_image, (0, 0))
|
||||
|
@ -76,7 +76,7 @@ def render_poster(data, poster):
|
|||
timeline_height = 64
|
||||
if timeline:
|
||||
timeline_image = Image.open(timeline)
|
||||
timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.ANTIALIAS)
|
||||
timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.LANCZOS)
|
||||
poster_image.paste(timeline_image, (0, frame_height))
|
||||
|
||||
# text
|
||||
|
@ -115,7 +115,7 @@ def render_poster(data, poster):
|
|||
logo_height = 32
|
||||
logo_image = Image.open(os.path.join(static_root, '..', '..', 'static', 'png', 'logo.png'))
|
||||
logo_width = int(round(logo_height * logo_image.size[0] / logo_image.size[1]))
|
||||
logo_image = logo_image.resize((logo_width, logo_height), Image.ANTIALIAS)
|
||||
logo_image = logo_image.resize((logo_width, logo_height), Image.LANCZOS)
|
||||
logo_left = text_width - text_margin - logo_width
|
||||
logo_top = text_bottom - text_margin - logo_height
|
||||
for y in range(logo_height):
|
||||
|
|
Loading…
Reference in a new issue