Copy the SVG detection from SVGCoder to the utils

This commit is contained in:
DreamPiggy 2020-02-26 12:14:50 +08:00
parent 4acd81177b
commit ac4dcbe316
1 changed files with 10 additions and 0 deletions

View File

@ -17,6 +17,7 @@
// Currently Image/IO does not support WebP
#define kSDUTTypeWebP ((__bridge CFStringRef)@"public.webp")
#define kSVGTagEnd @"</svg>"
@implementation NSData (ImageContentType)
@ -74,6 +75,15 @@
}
}
}
case 0x3C: {
if (data.length > 100) {
// Check end with SVG tag
NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(data.length - 100, 100)] encoding:NSASCIIStringEncoding];
if ([testString containsString:kSVGTagEnd]) {
return SDImageFormatSVG;
}
}
}
}
return SDImageFormatUndefined;
}