判断图片格式 发表于 2017-11-27 | 123456789101112131415161718192021+(NSString *)typeForImageData:(NSData *)data{ uint8_t c; [data getBytes:&c length:1]; switch (c) { case 0xFF: return @"jpeg"; case 0x89: return @"png"; case 0x47: return @"gif"; case 0x49: case 0x4D: return @"tiff"; } return nil;}