用于在云中托管的图像的Javascript灰度脚本 [英] Javascript grayscale script for images hosted in the cloud
问题描述
我想知道是否有办法在文件托管在AWS s3或其他东西上时使用javascript制作图像灰度/ b& w客户端。我找到了这个漂亮的小脚本:
http://www.permadi.com /tutorial/jsCanvasGrayscale/index.html
I am wondering if there is a way to make an image grayscale/b&w client side using javascript when the files are hosted on, say, AWS s3 or something. I have found this nice little script: http://www.permadi.com/tutorial/jsCanvasGrayscale/index.html
但是当您尝试将此应用于未托管在同一域中的图像时,您将获得
安全性错误,因为您正在执行跨站点操作。确切的错误(来自Chrome)是:
But when you try to apply this to images that are not hosted on the same domain, you get a Security Error because you're performing cross-site operations. The exact error (from Chrome) is:
Uncaught Error: SECURITY_ERR: DOM Exception 18
特别是我希望有一种方法可以将图像下载到字节数组然后逐像素地修改它,类似于上述脚本如何工作。
In particular I was hoping there was a way I could download the image into a byte array and then modify it pixel-by-pixel, similar to how the aforementioned script works.
注意:我不对在服务器端创建单独的图像感兴趣,因为我正在处理成千上万的图像喜欢这个功能即时工作。
Note: I am not interested in creating separate images on the server side, as I'm dealing with tens of thousands of images and would like this feature to work on the fly.
推荐答案
要跨域加载画布图像,您可能需要查看:< a href =http://www.maxnov.com/getimagedata/ =nofollow> http://www.maxnov.com/getimagedata/
To load canvas images across domains, you might want to look at that: http://www.maxnov.com/getimagedata/
这篇关于用于在云中托管的图像的Javascript灰度脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!