Skip to content

Commit

Permalink
Fix reading animation frames with pyav leading to truncated frames
Browse files Browse the repository at this point in the history
  • Loading branch information
laggykiller committed Nov 29, 2024
1 parent 09ca22b commit 83c53fe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sticker_convert/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def _frames_import_pyav(self) -> None:
rgba_array = yuva_to_rgba(frame_resized)

# Remove pixels that was added to make dimensions even
rgba_array = rgba_array[0:width_orig, 0:height_orig]
rgba_array = rgba_array[0:height_orig, 0:width_orig]
self.frames_raw.append(rgba_array)

def _frames_import_lottie(self) -> None:
Expand Down Expand Up @@ -622,12 +622,12 @@ def frames_resize(
self.res_h = height

scaling = 1 - (self.opt_comp.padding_percent / 100)
if width > height:
if width / self.res_w > height / self.res_h:
width_new = int(self.res_w * scaling)
height_new = int(height * self.res_w // width * scaling)
height_new = int(height * self.res_w / width * scaling)
else:
height_new = int(self.res_h * scaling)
width_new = int(width * self.res_h // height * scaling)
width_new = int(width * self.res_h / height * scaling)

with im.resize((width_new, height_new), resample=resample) as im_resized:
with Image.new(
Expand Down

0 comments on commit 83c53fe

Please sign in to comment.