Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const realSize = await this._sizeOfBuffer(buff);
- const buffSrc = await writeTempImage(buff, 'png');
- const { pathBmpImage, pathSVGImage } = this._svgBmp(type);
- await execSync(`convert ${buffSrc} -colorspace gray -threshold 50% ${pathBmpImage}`);
- await execSync(`convert ${pathBmpImage} ${pathSVGImage}`);
- await execSync(`convert ${pathSVGImage} ${buffSrc}`);
- await execSync(`convert ${buffSrc} -colorspace gray -threshold 50% ${pathBmpImage}`);
- if (isTransp) {
- await execSync(`potrace ${pathBmpImage} -s -t 10 -r 90 -o ${pathSVGImage}`);
- } else {
- await execSync(`potrace ${pathBmpImage} -s -t 20 -r 90 -o ${pathSVGImage}`);
- }
- if (isBackground) {
- await execSync(`convert -background none ${pathSVGImage} ${buffSrc}`);
- } else {
- await execSync(`convert ${pathSVGImage} -quality 100 ${buffSrc}`);
- }
- await execSync(`convert ${buffSrc} -resize ${realSize.width}x${realSize.height} ${buffSrc}`);
- buff = fs.readFileSync(buffSrc);
- this.unlinkSync([pathBmpImage, pathSVGImage, buffSrc]);
- return buff;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement