From f5f07a591aac945b32e731e26ad2b9f106d680b8 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 4 Dec 2020 20:00:05 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BA=D0=BE=D0=BD=D0=B2=D0=B5=D1=80=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/Reader/BookConverter/ConvertDjvu.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/core/Reader/BookConverter/ConvertDjvu.js b/server/core/Reader/BookConverter/ConvertDjvu.js index fb17ab8b..98dfadea 100644 --- a/server/core/Reader/BookConverter/ConvertDjvu.js +++ b/server/core/Reader/BookConverter/ConvertDjvu.js @@ -42,7 +42,7 @@ class ConvertDjvu extends ConvertHtml { }, abort); const tifFileSize = (await fs.stat(tifFile)).size; - const limitSize = 3*this.config.maxUploadFileSize; + let limitSize = 3*this.config.maxUploadFileSize; if (tifFileSize > limitSize) { throw new Error(`Файл для конвертирования слишком большой|FORLOG| ${tifFileSize} > ${limitSize}`); } @@ -53,7 +53,7 @@ class ConvertDjvu extends ConvertHtml { await fs.remove(tifFile); //конвертируем в jpg - await this.execConverter(mogrifyPath, ['-quality', '20', '-verbose', '-format', 'jpg', `${dir}*.tif`], () => { + await this.execConverter(mogrifyPath, ['-quality', '20', '-scale', '2048', '-verbose', '-format', 'jpg', `${dir}*.tif`], () => { perc = (perc < 100 ? perc + 1 : 40); callback(perc); }, abort); @@ -83,12 +83,17 @@ class ConvertDjvu extends ConvertHtml { await Promise.all(loading); //формируем текст + limitSize = 2*this.config.maxUploadFileSize; let title = ''; if (uploadFileName) title = uploadFileName; let text = `${title}`; for (const image of images) { text += `${image.data}`; + + if (text.length > limitSize) { + throw new Error(`Файл для конвертирования слишком большой|FORLOG| text.length: ${text.length} > ${limitSize}`); + } } return await super.run(Buffer.from(text), {skipCheck: true, isText: true, cutTitle: true}); }