dfa1234 / ngx-image-compress

Angular library for uploading and compressing images
https://image-library.app
MIT License
86 stars 37 forks source link

Cannot compress image of 103kb to fit in 1mb #106

Closed yarmoliq closed 1 year ago

yarmoliq commented 1 year ago

I'm using .uploadAndGetImageWithMaxSize(1) to read an image and compress it, but it fails to do this with this exact image, even though it is already fits. With other images that already fit 1mb it works fine.

The image: https://i.pinimg.com/736x/b1/14/da/b114da448d67cd47e22ef6b092dede46.jpg

dfa1234 commented 1 year ago

That is not an issue 103kb < 1mb So you can't compress (reduce the size) to a greater size.

yarmoliq commented 1 year ago

But your method hides upload functionality, so I cannot decouple it and check myself if this is already under the specified size. Also, as I said, other pictures work fine, even though they are smaller than 1mb. But ok

dfa1234 commented 1 year ago

Ok I understand, we need to check at the beginning if the required size is already there. Thank for your contribution to the algorithm

yarmoliq commented 1 year ago

Thank you 😊

dfa1234 commented 1 year ago

image I tested it and it's working exacely like this. You need to check the code on the demo web site + demo code to see how to do it (using promise error)