From 2c111d9936a10aa1bdf2835b1681e493679b339e Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Sat, 26 Sep 2020 19:20:27 +0200 Subject: [PATCH] slurp in the whole file from stdin because we might need to read it multiple times and mupdf needs to seek in it anyways --- plakativ.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plakativ.py b/plakativ.py index dad1029..d2d2288 100755 --- a/plakativ.py +++ b/plakativ.py @@ -1951,6 +1951,12 @@ def compute_layout( poster_border=False, ): doc = None + if hasattr(infile, "read"): + # we have to slurp in the whole file because we potentially read it + # in multiple times in case img2pdf is installed + # also, mupdf needs to be able to seek(), so we need to slurp it in + # anyways + infile = BytesIO(infile.read()) if have_img2pdf: # if we have img2pdf available we can encapsulate a raster image # into a PDF container