Is further Base64 PNG string compression possible?

I have a PNG image and got its string representation of Base64 PNG. It is still quite large, and I would like to know if it can be significantly compressed. Is it possible?

Background

I use Selenium 2 (Java) to take a screenshot of the current web page, convert it as a base64 string, and send this string to a JavaScript executor to recreate this image and do some image processing. But if this row size is too large, the server returns an exception.

+8
javascript image base64 compression selenium-webdriver
source share
2 answers

The simple answer: No - without losing the nature of the "printed line"

Typically, PNG already uses sophisticated compression, such as it is used in ZIP files. Therefore, compression before applying base64 encoding will give you a very limited reduction in size.

Applying compression after base64 encoding will again lead to binary data - in this case, you can simply skip the base64 encoding step.

+9
source share

If this is a network problem, not your row size, this worked for me when I sent my images to the mongo database.

Using Express.js , the default limit of bodyParser is 1056k so you can fix the problem by changing the limit as shown below.

 app.use(bodyParser.urlencoded({ limit: '50mb', extended: true })); app.use(bodyParser.json({ limit: '50mb' })); 
+1
source share

All Articles