Closed digimbyte closed 2 years ago
This library uses an iterative approach to compress images. The image size is reduced after each iteration. Default iteration is 10 times.
It is possible that in some marginal cases, the image is still larger than the maxSizeMB after the process.
You can put additional config to increase the number of iterations:
const options = {
maxSizeMB: 3,
maxIteration: 30
}
If the issue still exists, you may share the image file you used.
I have the following options:
const options = { maxSizeMB: 3, maxWidthOrHeight: 1200, onProgress: (percent: number) => { this.progressTracker.value = percent; }, useWebWorker: true, maxIteration: 10, exifOrientation: 1, fileType: 'jpg', initialQuality: 0.7, }
I tested it with a jfif image that was 134kb - it "compressed" the image to a jpg at 1.57MB is there a setting I should look out for? or is it a fault of the image format and its compression? because when I used the demo site, it saved it to 128kb - could you share the config you have in your demo example?