美文网首页
获取图片格式

获取图片格式

作者: 楠Y | 来源:发表于2017-04-07 11:29 被阅读5次

+ (NSString *)typeForImageData:(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;

}

相关文章

网友评论

      本文标题:获取图片格式

      本文链接:https://www.haomeiwen.com/subject/ytqhattx.html