diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2025-10-12 15:06:27 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2025-10-12 15:06:27 -0400 |
| commit | f9d5251dd78468d99fbd88eedaacdc4dede1a4cc (patch) | |
| tree | 463553811ef9c23dfa849b035b12ee7d982f7b5f /server/szurubooru/func/images.py | |
| parent | 1bec9ce49f85673a72e0fb78eb9a414309f7e64d (diff) | |
Update ffmpeg commands
Diffstat (limited to 'server/szurubooru/func/images.py')
| -rw-r--r-- | server/szurubooru/func/images.py | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/server/szurubooru/func/images.py b/server/szurubooru/func/images.py index e135d18..91ec0e3 100644 --- a/server/szurubooru/func/images.py +++ b/server/szurubooru/func/images.py @@ -42,20 +42,15 @@ class Image: return self.info["streams"][0]["nb_read_frames"] def resize_fill(self, width: int, height: int) -> None: - width_greater = self.width > self.height - width, height = (-1, height) if width_greater else (width, -1) - cli = [ "-i", "{path}", - "-f", - "image2", - "-filter:v", - "scale='{width}:{height}'".format(width=width, height=height), - "-map", - "0:v:0", + "-vf", + f"scale=min(iw*{height}/ih\,{width}):min({height}\,ih*{width}/iw),pad={width}:{height}:({width}-iw)/2:({height}-ih)/2:white", "-vframes", "1", + "-f", + "image2pipe", "-vcodec", "png", "-", @@ -81,12 +76,10 @@ class Image: [ "-i", "{path}", - "-f", - "image2", - "-map", - "0:v:0", "-vframes", "1", + "-f", + "image2pipe", "-vcodec", "png", "-", @@ -96,20 +89,12 @@ class Image: def to_jpeg(self) -> bytes: return self._execute( [ - "-f", - "lavfi", - "-i", - "color=white:s=%dx%d" % (self.width, self.height), "-i", "{path}", - "-f", - "image2", - "-filter_complex", - "overlay", - "-map", - "0:v:0", "-vframes", "1", + "-f", + "image2pipe", "-vcodec", "mjpeg", "-", |