feat: check artifact size when rendering thumbnails instead of silent enlarge
This commit is contained in:
1 parent
25daed583c
commit
945d4ec68d
1 file changed
+3
-3
@@ -182,11 +182,11 @@ def render_thumbnail(art: Artifact, hws: Iterable[int]) -> Iterator[Artifact]:
|
||||
|
||||
# check whether given artifact is square rectangle.
|
||||
if art.width != art.height:
|
||||
raise ValueError(f'Thumbnail render only accept square rectangle.')
|
||||
# scale artifact up to the maximum resolution hws if it is too small.
|
||||
raise ValueError('Thumbnail render only accept square rectangle.')
|
||||
# check whether given artifact is larger than the maximum resolution hws.
|
||||
max_hws = max(hws)
|
||||
if art.width < max_hws:
|
||||
art = art.resize((max_hws, max_hws), PIL.Image.Resampling.LANCZOS)
|
||||
raise ValueError('Given artifact is too small for rendering thumbnail.')
|
||||
|
||||
# render thumbnail
|
||||
for hw in hws:
|
||||
|
||||
Reference in new issue
Block a user