Closed jayu closed 7 months ago
Add web support
Make module cross-platform
Hey, I made an investigation on how to implement .cropImage on the web. In general, a solution could use canvas with 2d context and use drawImage (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage) method to prepare cropped Image, then I could be returned to the user. And here my doubts started.
.cropImage
canvas
2d
drawImage
For native platforms, the return value is URI to a local image which is a result of transformation. On the web is actually handier and easier to implement if a function would return
ImageData
CanvasRenderingContext2D.getImageData()
Image
<Img/>
base64
In addition, some users may experience issues with CORS when resizing will be implemented using canvas https://blog.codepen.io/2013/10/08/cross-domain-images-tainted-canvas/
I would like to start a discussion on the topic of web support. Personally I'm not sure if this feature is really needed.
Web support was added in 3.2.0
3.2.0
Feature Request
Add web support
Why it is needed
Make module cross-platform
Possible implementation
Hey, I made an investigation on how to implement
.cropImage
on the web. In general, a solution could usecanvas
with2d
context and usedrawImage
(https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage) method to prepare cropped Image, then I could be returned to the user. And here my doubts started.For native platforms, the return value is URI to a local image which is a result of transformation. On the web is actually handier and easier to implement if a function would return
ImageData
object https://developer.mozilla.org/en-US/docs/Web/API/ImageData generated byCanvasRenderingContext2D.getImageData()
Image
or its's DOM equivalent<Img/>
[https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image] usesbase64
under the hoodbase64
encoded imageIn addition, some users may experience issues with CORS when resizing will be implemented using canvas https://blog.codepen.io/2013/10/08/cross-domain-images-tainted-canvas/
I would like to start a discussion on the topic of web support. Personally I'm not sure if this feature is really needed.