Use gm to compress pictures, the picture quality is very poor, how to solve?

use gm to compress pictures, the picture quality is very poor, how to solve?

clipboard.png

as shown in the figure, 1.png is before compression and 2.png is after compression. The quality is poor.

const gm = require("gm").subClass({imageMagick: true});
gm("/Users/jiang/Downloads/1.png")
.resize(318, 211)
.noProfile()
.write("/Users/jiang/Downloads/2.png", function (err, data) {
  if (err) {
    throw err;
  }
});

this is the code

Mar.20,2021

.resize(200,0)     //w/h
.setFormat('JPEG')
.quality(70)       //: 0-100
.strip()
.autoOrient()

it is not recommended that you process images on your own server. On the one hand, the quality is difficult to guarantee. On the other hand, if the concurrency is too high, it is recommended that you connect to the third-party image processing, such as http://docs.upyun.com/cloud/u.. In addition, if you need to store pictures, you can also throw them directly on them. The reason for
to connect to a third party is that porn detection or other processing is likely to be required in the follow-up of the image, which is usually not done entirely on your own.

< hr >

the image processing library can also try this:
https://github.com/lovell/sharp

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46c04-4c2e5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46c04-4c2e5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?