Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting WebP via TIPDetectImageType and TIPDetectImageTypeFromFile? #57

Open
liamnichols opened this issue Aug 21, 2020 · 1 comment

Comments

@liamnichols
Copy link
Contributor

Hey! Hope you don't mind me bugging you about WebP related stuff even more? 馃槵

I was looking at using TIPDetectImageTypeFromFile for convenience in my project (usage not directly related to the rest of TIP) and I noticed that prior to iOS 14, these methods aren't able to detect when a file or data is WebP.

It's because these methods first attempt to use CGImageSourceRef to detect the type before falling back to magic number checks of the data however CoreGraphics in the iOS 13SDK doesn't recognise WebP as it wasn't added until the iOS 14 SDK (I've verified that it works when building with the 14SDK) and the TIPDetectImageTypeViaMagicNumbers magic number fallback only detects BPM, JPEG, GIF and PNG.

Do you think it's worth updating this check to look for the WebP header/signature/magic numbers?

I can relatively easily wrap and extend in my own code but I wasn't sure if other parts of the TIP project were expecting these methods to detect WebP or not?

It's a little trickier to add support since the header also includes the file size (https://developers.google.com/speed/webp/docs/riff_container) so I'm not sure of the best way to adjust the existing code to support this but am happy to help and dig into it a little more if you think it's worth it?

Let me know your thoughts, thanks!

@liamnichols
Copy link
Contributor Author

After plodding thought the codec catalog code, I realised that it seems to work in TIP by iterating the codecs and checking tip_detectDecodableData on each of them so it's a non-issue if you use TIP directly.

I guess the confusion came as after looking at TIPImageTypes.h, I kind of expected that the detection methods would work for all of the TIPImageType constants declared but I guess WebP is a kind of tricky one since its iOS 14+ officially

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant