Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios剪切后输出为黑色(透明图片) #13

Open
assursu opened this issue Apr 3, 2019 · 8 comments
Open

ios剪切后输出为黑色(透明图片) #13

assursu opened this issue Apr 3, 2019 · 8 comments

Comments

@assursu
Copy link

assursu commented Apr 3, 2019

截取 canvas 坐标,点在了 canvas 外,无法获取图像

@lijiayi01
Copy link

lijiayi01 commented May 28, 2019

这是ios拍摄图片角度问题。
解决方案:
1.引入exif库,取到图片orientation
2. 在manual-crop/index.js里做一下偏转处理(只截取了部分代码)
function handleCrop (info, params, resolve) {
let $el
// 旋转图片
if (params.angle > 0) {
$el = rotateImage(info.element, params.angle)
info.width = params.naturalWidth
info.height = params.naturalHeight
info.element = $el
}
if(info.orientation == 6){
$el = rotateImage(info.element, 90)
info.width = params.naturalWidth
info.height = params.naturalHeight
info.element = $el
}else if(info.orientation == 8){
$el = rotateImage(info.element, 270)
info.width = params.naturalWidth
info.height = params.naturalHeight
info.element = $el

}else if(info.orientation == 3){
$el = rotateImage(info.element, 180)
info.width = params.naturalWidth
info.height = params.naturalHeight
info.element = $el
}

其实作者已经给出了解决方案,只要未考虑ios拍摄问题而已。

@HShao0130
Copy link

请问解决了吗?

@lijiayi01
Copy link

lijiayi01 commented Jun 19, 2019 via email

@HShao0130
Copy link

@lijiayi01 可以了。感谢

@HShao0130
Copy link

@lijiayi01 你好,按照你提供的思路现在遇到一点问题,竖屏拍照现在已经没问题了,但是横屏拍照还是会有同样的问题。使用这个方法之前是横竖都会有问题的。下面是我的代码:

const self_img = document.createElement('img');
self_img.src = info.base64;
EXIF.getData(self_img, function () {
  info.orientation = EXIF.getTag(this, 'Orientation');
  console.log('Orientation:' + info.orientation);
});
alert(info.orientation)
if (info.orientation == 6) { // 竖屏
    $el = rotateImage(info.element, 90)
    info.width = params.naturalWidth
    info.height = params.naturalHeight
    info.element = $el
} else if (info.orientation == 8) { // 倒立竖屏
    $el = rotateImage(info.element, 270)
    info.width = params.naturalWidth
    info.height = params.naturalHeight
    info.element = $el
} else if (info.orientation == 3) {
    $el = rotateImage(info.element, 180)
    info.width = params.naturalWidth
    info.height = params.naturalHeight
    info.element = $el
}

@lijiayi01
Copy link

@lijiayi01 你好,按照你提供的思路现在遇到一点问题,竖屏拍照现在已经没问题了,但是横屏拍照还是会有同样的问题。使用这个方法之前是横竖都会有问题的。下面是我的代码:

const self_img = document.createElement('img');
self_img.src = info.base64;
EXIF.getData(self_img, function () {
  info.orientation = EXIF.getTag(this, 'Orientation');
  console.log('Orientation:' + info.orientation);
});
alert(info.orientation)
if (info.orientation == 6) { // 竖屏
    $el = rotateImage(info.element, 90)
    info.width = params.naturalWidth
    info.height = params.naturalHeight
    info.element = $el
} else if (info.orientation == 8) { // 倒立竖屏
    $el = rotateImage(info.element, 270)
    info.width = params.naturalWidth
    info.height = params.naturalHeight
    info.element = $el
} else if (info.orientation == 3) {
    $el = rotateImage(info.element, 180)
    info.width = params.naturalWidth
    info.height = params.naturalHeight
    info.element = $el
}

可以提供一下设备系统,我测试系统为:6sp,10.3.1

@HShao0130
Copy link

@lijiayi01 测试设备:iphonex , ios 12.3.1

@lijiayi01
Copy link

lijiayi01 commented Jun 20, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants