From 0eadd8fcda4ac734efba4944dea6fbc519d83a67 Mon Sep 17 00:00:00 2001 From: LEdoian Date: Wed, 5 Dec 2018 23:42:26 +0100 Subject: [PATCH] =?UTF-8?q?Korekturov=C3=A1tko:=20Snad=20fix=20rozbit?= =?UTF-8?q?=C3=A9ho=20ImageMagicku?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- korektury/models.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/korektury/models.py b/korektury/models.py index 1430ec75..e5b6e01a 100644 --- a/korektury/models.py +++ b/korektury/models.py @@ -82,16 +82,25 @@ class KorekturovanePDF(models.Model): self.stran = 0 while True: res = subprocess.call([ - "convert", - "-density", "180x180", - "-geometry", " 1024x1448", - "%s[%d]" % (self.pdf.path, self.stran), - os.path.join( + #Parametry inspirovány chybovou hláškou imagemagicku + "gs", + "-sstdout=%stderr", + "-dSAFER", + "-dNOPAUSE", + "-dBATCH", + "-dNOPROMPT", + "-sDEVICE=pngalpha", + "-r180x180", + "-dFirstPage=%d" % (self.stran+1), + "-dLastPage=%d" % (self.stran+1), + "-sOutputFile="+os.path.join( dirname, - "%s-%d.png" % (self.get_prefix(), self.stran) - ) + "%s-%d.png" % (self.get_prefix(), self.stran)), + "-f%s" % (self.pdf.path) ]) - if res == 1: + if not os.path.exists(os.path.join( + dirname, + "%s-%d.png" % (self.get_prefix(), self.stran))): break self.stran += 1 # Změnil se počet stran, ukládáme