Last active
August 29, 2015 14:04
-
-
Save ruandao/db8691f86d87fa97b0a8 to your computer and use it in GitHub Desktop.
mime type of nsdata of image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (NSString *)contentTypeForImageData:(NSData *)data { | |
| uint8_t c; | |
| [data getBytes:&c length:1]; | |
| switch (c) { | |
| case 0xFF: | |
| return @"image/jpeg"; | |
| case 0x89: | |
| return @"image/png"; | |
| case 0x47: | |
| return @"image/gif"; | |
| case 0x49: | |
| case 0x4D: | |
| return @"image/tiff"; | |
| } | |
| return nil; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment