如何将方向数据写入UIImage iOS SDK [英] How to write orientation data to the UIImage iOS SDK
问题描述
我有一个问题,我有一个UIImage从imagePicker(相机不是库),但当我写它到文件与[UIImageJPEGRepresentation writeToFile:atomically:]我丢失方向数据(所有图像都是横向),我使用一些代码与图像变换,但它需要太长的大约1,5 - 2秒每个图像,我的问题是如何不松散方向?也许我可以写它到EXIF数据?
Thx的帮助。
I have a problem i got a UIImage from imagePicker (camera not library) but when i write it to file with [UIImageJPEGRepresentation writeToFile: atomically:] i'm loosing orientation data(all images are in landscape), i used some code with image transformation, but it take too long about 1,5 - 2 sec per image, my question is how to not loose orientation ? Maybe i can write it to EXIF data ? Thx for help.
编辑:
Thx到Jonathan Cichon,现在我得到了一个图像方向与UIImagePickerControllerMediaMetadata i got(Orientation = 6),但是如何存储到jpg文件? (再次用[UIImageJPEGRepresentation writeToFile:atomically:] proc保存文件)
Thx to Jonathan Cichon, now i got a image orientation with UIImagePickerControllerMediaMetadata i got (Orientation = 6), but how to store it to jpg file ? (again i saved file with [UIImageJPEGRepresentation writeToFile: atomically:] proc)
推荐答案
查看这篇文章了解如何存储EXIF数据的信息。如果我记得正确,你可以使用UIImagePickerControllerMediaMetadata,因为它是。至少你应该在这个字典中找到所有的necassary取向信息来创建你的EXIF数据。
Look at this post for information on how to store EXIF data. If i remember correctly you can use the UIImagePickerControllerMediaMetadata as it is. At least you should find all necassary orientation information in this dictionary to create your EXIF data.
查看关联的帖子,并替换第一行
NSData * jpeg = UIImageJPEGRepresentation(yourImage, 1);
这篇关于如何将方向数据写入UIImage iOS SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!