From 34b95a23ad0763bbba189ee60a10567c9c3daafe Mon Sep 17 00:00:00 2001 From: rymate1234 Date: Wed, 16 Jun 2021 18:51:14 +0100 Subject: [PATCH] > QA feedback --- lib/blur.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/blur.js b/lib/blur.js index 0dad9ec..097f7a8 100644 --- a/lib/blur.js +++ b/lib/blur.js @@ -45,10 +45,10 @@ class Blur extends DarkroomStream { return mask } - _createSVG(type, image, size) { + _createSvg(mask, type, image, size) { const base64 = image.toString('base64') const xml = ` - ${this.mask} + ${mask} @@ -56,13 +56,11 @@ class Blur extends DarkroomStream { ` - const mask = Buffer.from(xml) - - return mask + return Buffer.from(xml) } - _createBlurred(cb) { - const outImage = sharp(this.svg) + _createBlurred(svg, cb) { + const outImage = sharp(svg) if (this.format) { outImage.toFormat(this.format, { quality: this.quality }) @@ -94,14 +92,16 @@ class Blur extends DarkroomStream { this.format = imageFileType.ext } + let svg + try { - this.mask = this._createMask(info) - this.svg = this._createSVG(imageFileType, image, info) + const mask = this._createMask(info) + svg = this._createSvg(mask, imageFileType, image, info) } catch (e) { return this.output(e) } - this._createBlurred((error, output) => { + this._createBlurred(svg, (error, output) => { if (error) return this.output(error) this.output(null, output) })