bergben/ng2-img-tools

ng2-img-tools is not able to compress/resize some images in png format

Closed this issue · 8 comments

Hi bergben.... I am using ng2-img-tools since a while.It's working fine with all jpeg files,But when I tried to upload some png image files.. Im getting the below error..
compressedFile: File, reason: "Could not find the correct compress…", error: "MAX_STEPS_EXCEEDED"....
It's working fine when I rename the same png file to jpeg.... Please help..

Hi @LokiKartik
Thanks for reporting this.
You are using "version": "0.1.7" right? I have to debug this, can you tell me the maxSizeInMB you are using and provide me an image that doesn't work? I would need the image in the very original state...

Yup I'm using version 0.1.7 and the maxSizeInMB is 0.1. when I change this to 0.2 it's working well... please find the below image..
Image

Just wanna make sure Github is not compressing the image you shared: The image has a size of 287 KB (294.180 Bytes) right? I am gonna try it ASAP

Yaa... I already checked it.. github is not compressing the image size... it's exactly 294.180 Bytes..

Ok so I have created a Plunker: https://plnkr.co/edit/Y8JzvhYPJvcN2CJPhWDk
I think I found the problem, could you please try if the compression works for your png's in the Plunker? Allow the popups, a new tab will be opened with the resulting compressed image.

By the way: You are using a very low value for maxSizeInMB of 0.1, it is highly likely that some (bigger) images won't be able to be compressed far enough to fit that value, therefore you should most definetly catch that case as seen in the example I created for you for that in the Plunker in src/app.component.ts on line 34 to 37.

Thanks for responding quickly @bergben ...
It's working well in your example provided in plunker. But not working with the one I have. Am I using the older version.... I installed ng2-img-tools with command "npm install ng2-img-tools"...

Thanks for checking @LokiKartik. I am glad to hear that it works in the plunker. No the plunker is using the service directly in src/ng2-img-max.service.ts, not from npm. I am gonna release a new version in a few hours that should fix this issue.

Sorry, didn't get to it earlier, this issue should be solved with 0.1.8 @LokiKartik