summaryrefslogtreecommitdiff
path: root/server/szurubooru/func/images.py
diff options
context:
space:
mode:
Diffstat (limited to 'server/szurubooru/func/images.py')
-rw-r--r--server/szurubooru/func/images.py31
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",
"-",