Ios 如何检测图像是否不是由iPhone摄像头拍摄的?
我目前正在使用Ios 如何检测图像是否不是由iPhone摄像头拍摄的?,ios,iphone,uiimage,Ios,Iphone,Uiimage,我目前正在使用UIImage的imageOrientation属性来确定在相机拍摄照片后是否将照片翻转到横向: //3 is upright //2 is upside-down //1 is button on the left //0 is button on the right if (self.imageTakenOrSelected.imageOrientation == 1){ //Taken landscape with button the left
UIImage
的imageOrientation
属性来确定在相机拍摄照片后是否将照片翻转到横向:
//3 is upright
//2 is upside-down
//1 is button on the left
//0 is button on the right
if (self.imageTakenOrSelected.imageOrientation == 1){ //Taken landscape with button the left
UIImage *flippedImage = [UIImage imageWithCGImage:self.imageTakenOrSelected.CGImage scale:self.imageTakenOrSelected.scale orientation:UIImageOrientationRight];
self.imageTakenOrSelected = flippedImage;
} else if (self.imageTakenOrSelected.imageOrientation == 0){ //Taken landscape with button the right
UIImage *flippedImage = [UIImage imageWithCGImage:self.imageTakenOrSelected.CGImage scale:self.imageTakenOrSelected.scale orientation:UIImageOrientationRight];
self.imageTakenOrSelected = flippedImage;
}
目前,这对相机拍摄的照片很好,但我注意到,当涉及到截屏图片或从web下载的图片时,默认方向总是设置为横向,不管图片是否真正处于横向
我的问题是:
CGFloat width = [image width];
CGFloat height = [image height];
if (width > height) {
// image is landscape
} else {
// image is portrait
}
考虑查看EXIF信息(IMAIO框架)