Advertisement
KoctrX

Untitled

Feb 17th, 2021
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. const realSize = await this._sizeOfBuffer(buff);
  2.  
  3. const buffSrc = await writeTempImage(buff, 'png');
  4. const { pathBmpImage, pathSVGImage } = this._svgBmp(type);
  5.  
  6. await execSync(`convert ${buffSrc} -colorspace gray -threshold 50% ${pathBmpImage}`);
  7. await execSync(`convert ${pathBmpImage} ${pathSVGImage}`);
  8. await execSync(`convert ${pathSVGImage} ${buffSrc}`);
  9.  
  10. await execSync(`convert ${buffSrc} -colorspace gray -threshold 50% ${pathBmpImage}`);
  11.  
  12. if (isTransp) {
  13. await execSync(`potrace ${pathBmpImage} -s -t 10 -r 90 -o ${pathSVGImage}`);
  14. } else {
  15. await execSync(`potrace ${pathBmpImage} -s -t 20 -r 90 -o ${pathSVGImage}`);
  16. }
  17.  
  18. if (isBackground) {
  19. await execSync(`convert -background none ${pathSVGImage} ${buffSrc}`);
  20. } else {
  21. await execSync(`convert ${pathSVGImage} -quality 100 ${buffSrc}`);
  22. }
  23.  
  24. await execSync(`convert ${buffSrc} -resize ${realSize.width}x${realSize.height} ${buffSrc}`);
  25. buff = fs.readFileSync(buffSrc);
  26. this.unlinkSync([pathBmpImage, pathSVGImage, buffSrc]);
  27. return buff;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement