seanooi / iOS-WebP

Google's WebP image format decoder and encoder for iOS
http://seanooi.github.io/iOS-WebP/
MIT License
857 stars 138 forks source link

Color shift when encoding UIImage files #10

Open skochan opened 10 years ago

skochan commented 10 years ago

[This was posted as part of another topic, which was closed....not by me). So I moved it here

Here are two images, JPEG and webP. Notice the big color shift. The UIImage that's given to the JPEG and webP compressors is generated from a cocos2D openGL layer that gets rendered into a UIImage. I'm not sure if that's affecting the webP encoder, but as you can see, the color shift is noticeable. Again, If I decompress the JEPG and then recompress with webP, I have no problem--there is no color shift

m4

screen shot 2014-05-01 at 10 42 16 am

newacct commented 9 years ago

To reproduce a color shift, take the Demo project, and change the following in ViewController.m:

Change static CGFloat alpha = 0.6f; to static CGFloat alpha = 1.0f;

Add the following lines after UIImage *demoImage = [UIImage imageNamed:imageFileName];:

UIGraphicsBeginImageContext(demoImage.size);
[demoImage drawInRect:CGRectMake(0, 0, demoImage.size.width, demoImage.size.height)];
demoImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
harryhorn commented 9 years ago

@skochan I am seeing the same issue and thanks for the tip to convert it to a Jpeg and only then convert to WebP. like @newacct I am also downscaling the image so now I downscale, convert to jpeg and then to weep. Of course this causes extra processing but solves the issue as a workaround.

pawelnathan commented 8 years ago

I am seeing the same issue here. Has anybody found the reason for this?

kross51 commented 3 weeks ago

This should fix the issue... I attached full file for simplicity... rename as .m :)

UIImage+WebP.txt

xiaoyao8023 commented 3 weeks ago

这是来自QQ邮箱的自动回复邮件。   您好,我已经收到您的邮件了,我会尽快回复您。