JonathanBristow
JonathanBristow

Reputation: 1065

Node.js - Detecting Image Optimization

I am building an application which allows users to upload images to a post.

My issue is that some of these images are 10MB plus. I am currently optimising these using a Node.js module which lowers the file size. It does this by re-creating the image with a quality score of 70.

The issue I have is that some users optimize images before uploading. If an image has already been optimized I don't want to lower the quality any further.

Is there anyway I can detect the quality of an image before it is processed?

Upvotes: 1

Views: 563

Answers (2)

Dileephell
Dileephell

Reputation: 630

with imagemagick you can first identify the size and then convert it into small size or crop it

Upvotes: 0

siavolt
siavolt

Reputation: 7077

If you use multer, you can see that in size field, if you have only buffer you can use .length method, example:

buffer.length() // return 255bytes or 255000 255Kb

Upvotes: 0

Related Questions