Closed jzzfs closed 3 years ago
imgWindow.document
error is in the demo code: https://codesandbox.io/s/antd-img-crop-4qoom5p9x4
And demo code updated.
Thanks. The sandbox err must've been a coincidence but the mobile error still persists -- I'm unable to neither upload saved pictures nor freshly taken ones. Mind you, the cropper is able to render the canvas but the "OK" click results in a blacked out image. Can you check on your phone?
I've cloned the module and everything works fine until the canvas modifications begin.
In other words, if I skip the canvas manipulations (zoom/move/rotate) and resolve the naturalImg.src
and don't export the canvas to the file, the naturalImage
b64 source renders correctly.
The problem cannot be the canvas -> blob -> file conversion because if I resolve canvas.toDataURL('image/jpeg')
, it results in an already "corrupted" data url...
This makes me think it may be some mobile canvas manipulation inconsistency?
There are some issues about it before:
https://github.com/nanxiaobei/antd-img-crop/issues/30 https://github.com/nanxiaobei/antd-img-crop/issues/55
PR has been added before, but I don't know why there are still problems. At present, I have no time to solve this problem, sorry.
OK, thanks for the heads-up.
For those that stumble on this in the future -- it turns out, canvas dimension vary across devices. The best bet it to downsize/compress the image before passing it to the cropper. More on this in this thread.
Issue Both of these two processes end up with a blacked-out preview:
Reproducible on https://codesandbox.io/s/antd-img-crop-4qoom5p9x4 on any mobile browser -- I've tested
Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1
)Mozilla/5.0 (Linux; Android 9; Mi A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.210 Mobile Safari/537.36
)Video:
Screenshot: