ngx-image-compress icon indicating copy to clipboard operation
ngx-image-compress copied to clipboard

Image Size in code is 10 times the actual size while compressing

Open aviralgoyal opened this issue 2 years ago • 3 comments

Hi David

When uploading file as per windows File size is 1.56 MB.

image

But on running Ngx Compress the byte count is coming at 10 MB. In debug mode you can see the byte Count in yellow as 10.42

image

I can send you the image for testing on your email. Please let me know, I don't want to upload it on public domain.

And it is giving this error on client side, which I can't reproduce. `cannot contain special characters in <Path of file> for this file itself. I don't know the reason.

Can you please guide what seems to be the issue.

aviralgoyal avatar Jul 18 '22 10:07 aviralgoyal

Hi @aviralgoyal can you send the image you used by mail [email protected] thank

dfa1234 avatar Aug 03 '22 11:08 dfa1234

@aviralgoyal anyway I think I know what is your problem already. You used ratio=99 and quality=100 First, ratio 99 is a strange choice (but it's up to you) But quality 100 is just wrong. Your are compressing with 0% rate of loss in quality. That's can't happen. It will only increase the size. Please use some realistic number (70 or 80 are very good quality already) Or anything bellow 100. 100 is a bad choice, maybe we could log some error for the user

dfa1234 avatar Aug 03 '22 11:08 dfa1234

@dfa1234 I've sent you the mail with the image. This problem is happening in very few images. So I don't think 99 is the issue. But do let me know if something else is amiss. Thank you in advance.

aviralgoyal avatar Aug 09 '22 13:08 aviralgoyal

From the image you provided I see that an error is indeed throw. So there is 2 different things here:

  • First I repeat that using 100 or 99 quality ratio in jpeg transformation is not enough, it's very likely that you will get a jpeg bigger than the original image - this point is closed for me. You can refer to the documentation about ratio compression in the READ ME of this repo
  • Your image in particular is throwing an error and it's a problem that could happening to this particular image (some defect in it). Or there is something happening in our code. So for this issue only, I marked the ticket "to be investigated", we will look from where this error is happening to understand the issue

dfa1234 avatar Dec 21 '22 08:12 dfa1234