如何通过 POST 发送方向正确的图片
我想通过 http post 请求将图像发送到 saas。 该图像由 iPhone 相机拍摄或从 iPhone 库中选择。 问题是 iPhone 似乎在 exif 数据中对图像的方向进行了编码,因此当我尝试通过 POST 发送图像时,服务会以错误的方向详细说明它(首先检查 exif 标签不太明智)。 有人可以发布一个片段来检查 exif(如果有)并制作具有正确方向的新图像吗?
感谢您的帮助。
I want to send an image to a saas via an http post request.
That image is taken by the iPhone camera or choosen from the iPhone library.
The problem is that iPhone seems to encode the orientation of the image in the exif data, so when I try to send the image via POST the service elaborate it with the wrong orientation (it isn't so smart to check exif tag first).
Can someone post a snippet that check the exif (if any) and make a new image with correct Orientation?
Thank you for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
冒着鼓励复制粘贴编程的风险,我会说我使用找到的代码 此处 执行相同的操作。它将获取一个 UIImage,检查 EXIF 数据,然后返回一个已调整为匹配的新 UIImage,以便您的服务无需担心它。
请记住,您可能需要稍微调整它以满足您的特定需求。但这绝对是一个起点。
At the risk of encouraging copy-paste programming, I'll say that I use the code found here to do the very same thing. It'll take a UIImage, check the EXIF data, and return you a new UIImage that has been adjusted to match so your service won't need to worry about it.
Just keep in mind you may need to tweak it slightly to match your specific needs. It's definitely a starting point though.