mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
39 lines
759 B
Objective-C
39 lines
759 B
Objective-C
//
|
|
// UIImage+contentTypes.m
|
|
// Signal
|
|
//
|
|
// Created by Frederic Jacobs on 21/12/14.
|
|
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "UIImage+contentTypes.h"
|
|
|
|
@implementation UIImage (contentTypes)
|
|
|
|
- (NSString*)contentType {
|
|
uint8_t c;
|
|
[UIImagePNGRepresentation(self) getBytes:&c length:1];
|
|
|
|
switch (c) {
|
|
case 0xFF:
|
|
return @"image/jpeg";
|
|
case 0x89:
|
|
return @"image/png";
|
|
case 0x47:
|
|
return @"image/gif";
|
|
case 0x49:
|
|
break;
|
|
case 0x42:
|
|
return @"image/bmp";
|
|
case 0x4D:
|
|
return @"image/tiff";
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
- (BOOL)isSupportedImageType {
|
|
return ([self contentType]?YES:NO);
|
|
}
|
|
|
|
@end
|