YYImage icon indicating copy to clipboard operation
YYImage copied to clipboard

Crash on image encoding (WebPPictureImportRGBA)

Open DomenicoGonnelli opened this issue 5 years ago • 1 comments

Hi, I'm using this lib and I have a problem to convert png image on webp. In particular when I try to encode png Data, App crashes on line 1284 if(!WebPPictureImportRGBA(&picture, buffer.data, (int)buffer.rowBytes)) goto fail;

I find a possible solution of problem: analyzing the code I see that variable "lossless" is used to set picture.use_argb, so if you pass NO app crash on png image, if you force YES on YYImageCoder.m - line 2683

CFDataRef frameData = YYCGImageCreateEncodedWebPData(image, YES, _quality, 4, YYImagePresetDefault);

it works.

I suggest to modify the switcher on YYImageCoder (line 2357) in .. case YYImageTypeWebP: { _quality = 0.8; _lossless = YES; } ...

DomenicoGonnelli avatar Jun 08 '20 15:06 DomenicoGonnelli

Yes, adding _lossless = YES; solved the issue for me 👏 Thanks for the solution

rebeloper avatar Oct 27 '20 09:10 rebeloper