-
Notifications
You must be signed in to change notification settings - Fork 108
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
Alpha channel heuristic when not using ImageWorker doesn't deal with uppercase file extensions #493
Comments
This fix solves an issue when the image worker is not being used, so Lightning processes images on the main thread. There is a simple check for `.png` to toggle whether or not the image has an alpha channel. This however gives an issue when a `.PNG` is used. Introduced a simple lowerCase cast to be able to work with both `.png` and `.PNG`. Additionally added some (quick and dirty) vitest cases to validate the above changes. Resolves: rdkcentral#493
Hi @pascalatfetch ! Thanks for reporting, I made a tiny fix to straighten this out. Hope to get this into the next release! |
@wouterlucas Great work. Do you think the image worker ignoring the |
During my tests it didn’t seem to ignore the hasAlpha flag on the function itself. This might be higher up the chain if that is the case, I can look into it but suggest we move this along for the next release. |
I don't think it's super important. Just saw this as a discrepancy. When providing the Instead, on worker execution, the A fix for that might be to process |
ah yes, thanks for clarifying. It indeed seems to be ignored on the image worker because it relies on the mimeType: Although I agree that doesn't make sense and it should probably be included when evaluating the alpha also on the image worker. I do think the mimeType itself is solid way to check for the alpha channel, not sure if having an override is necessary at this point. |
It is certainly awkward when image URLs don't include |
I tried loading an externally supplied file with
.PNG
extension, and the alpha channel wasn't clear.It seems that the heuristic is to just look at the file path, whereas the ImageWorker detects mime types.
That said, there is a flag
hasAlpha
which the ImageWorker subsequently ignores.Should the non-worker based code path use a
FileReader
and do mime type detection as well, or is that too much of a performance hit? At the very least the heuristic string comparison should ignore case.Looking into this, the code responsible here is this line:
https://github.com/rdkcentral/Lightning/blob/master/src/platforms/browser/WebPlatform.mjs#L270
The text was updated successfully, but these errors were encountered: