Open liamnichols opened 4 years ago
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
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 theTIPDetectImageTypeViaMagicNumbers
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!