-
Notifications
You must be signed in to change notification settings - Fork 91
Encoding Results in Washed-Out Colors #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems Bug of color space decoding/encoding. Any demo ? And I remember, the encode of WebP does not support some color format. In history we use the vImage (vImageConvert_AnyToAny) to convert like ARGB8 -> RGB8 (BGRA8 -> RGB8) to use libwebp. But after that we revert back to use libwebp's own processing. Seems bug maybe related to this. |
Seems not bug of Seems bug of |
Where's your source PNG image ? (You means, you convert PNG to JPEG and WebP. The converted JPEG and WebP use different color space ?) |
I'm sure by changing the color space to use CGImage's color space, the issue been fixed. pexels-egor-kamelev-920163.zip See: |
Thank you for this quick reply! Seems like your instinct with it being an issue with the color space has been spot on. You are so fast. Thank you so much for looking into this. ❤️ |
Just use that PR's commits and test by yourself. Then I'll merge in and release a patch version |
I just tried the PR and for most of my tests it spits out perfect results. 🤩 Although, the problem still persists for all HEIC files from my iPhone and for one of the PNGs I tested. Do you have another quick idea? |
For you case, actually we should not only ensure the Because it's "Transcoding", right ? Actually, it do 3 steps:
You want the image buffer in 1. match the new image buffer in 3., so all of thesse steps need to check again |
How do you get the original input image, using the SDWebImage's API (NSImage.sd_imageWithData) or AppKit API (like NSImage(data:)` ? Which means, which |
Using AppKit's PNG decoder seems work well. Is this SDWebImage's PNG decoder's bug ? |
Even use the I guess is your App's business code, which does not give the correct input (before feeding into You can even use LLDB debugger, to visualize the image object (NSImage) in memory and preview.app, is that match what you see in Mac's Finder ? |
And one intersting thing is that your |
But whatever, I guess It's a bug from either your business code, or the input format's decoder (like SDWebImage, which use Apple's ImageIO for PNG decode) Or even Apple's bug, like Apple's PNG decode contains bug on macOS 14.0. I don't know whether they fix that bug or not. (See: SDWebImage/SDWebImage#3605). Anyway, for now, I just release SDWebImageWebPCoder with new version. 0.14.2 |
Thank you for your quick response as always. Sorry it took me so long to get back to you. Sorry for the confusion. My images were a bit smaller, because I used I now use the following code to use this library: static func convertToWebPData(source: URL) throws -> Data {
let image = NSImage(byReferencing: source)
let data = SDImageWebPCoder.shared.encodedData(with: image, format: .webP)
guard let data else {
throw ImageConverterError.cannotConvertToWebP
}
return data
} Thank you for shipping 0.14.2 with improvements. I checked the last 2 zip files you attached here and see the same issue on the photo with the woman in the desert. If you look closely, you can see that the colors of her gold chain are washed-out and duller than in the original. But 0.14.2 is already a huge improvement. The problem still persists when I try to convert photos taken with my iPhone camera. Colors get washed-out and dull. Maybe you have another idea? I hope you are having a nice week so far. |
macOS:
14.1
Xcode
15.0
SDWebImage
5.18.4
SDWebImageWebPCoder
0.14.1
I tried to implement this package into an existing macOS app, when I noticed that the conversion results in washed-out colors. I tried this with converting PNGs and JPGs to WebP so far. Are there any options to preserve the original image colors?
Tried many different option combinations, but the images in the ZIP were created with
.encodeCompressionQuality = 0.8
and anNSImage.
Thank you for working on this project.
I hope you are having a nice day.
examples.zip
The text was updated successfully, but these errors were encountered: