您的位置:首页 > 移动开发 > IOS开发

七牛IOS和数码相机竖排,图片旋转问题处理

2017-12-06 17:45 323 查看
思路:

针对获取原信息中含有(orientation)参数,值为Right-top和Left-bottom会被旋转:

{"size":1640252,"format":"jpeg","width":3456,"height":2304,"colorModel":"ycbcr","orientation":"Left-bottom"}


方法一:?imageView2/0/format/jpg,给图片统统加后缀(简单粗暴)

方法二:?imageMogr2/auto-orient,通过判断orientation,加此后缀,防止放入img标签图片转向:

js处理思路如下(java同理):

function getImageFormat(key) {
var img = "";
$.ajax({
type: "get",
async : true,
dataType: "json",
url: imagePrefix+key+"?imageInfo",
success: function (data) {
var orientation = data.orientation;
if(typeof(orientation) != "undefined"){
if(orientation == "Right-top" || orientation == "Left-bottom"){
img = imagePrefix+key+"?imageMogr2/auto-orient";
//或者img = imagePrefix+key+"?imageView2/0/format";
}
}
}
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: