使用画布从图像中删除像素?

发布于 2024-12-25 00:32:41 字数 231 浏览 2 评论 0原文

我可以使用画布按颜色从图像中删除像素,使该区域透明吗?

如果是这样...

我可以使用其他服务器上托管的图像来执行此操作吗?

在服务器端做这个会更好吗? https://github.com/LearnBoost/node-canvas

谢谢!

Can I remove pixels from an image by color using canvas, making that area transparent?

If so...

Can I do this with images hosted on other servers?

Would it be better to do this server-side? https://github.com/LearnBoost/node-canvas

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一腔孤↑勇 2025-01-01 00:32:41

此处已完成此操作:https://developer.mozilla。 org/en-US/docs/Web/API/Canvas_API/Manipulated_video_using_canvas

它有一个活生生的例子,看起来效果很好。我建议你检查一下。

This has been done here: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Manipulating_video_using_canvas

It has a live example which seems to work nicely. I recommend you check it out.

執念 2025-01-01 00:32:41

正如其他人所说,这是可能的,Dessus 的链接将对此有所帮助。

但是,出于安全原因,您将无法对其他服务器上托管的图像执行此操作。如果您将远程图像写入画布,它会将画布视为“受污染”,并会通过 JavaScript 安全异常进行处理。因此,您只能对与执行操作的代码位于同一服务器上的图像执行此操作。

As others have said, this is possible and Dessus' link will help with that.

However you won't be able to do this with images hosted on other servers for security reasons. If you write a remote image to canvas, it treats the canvas as "tainted" and will through a JavaScript security exeption. So you'll only be able to do it on images that are on the same server as the code that performs the manipulation.

甜心 2025-01-01 00:32:41

像素操作

检查上面的链接。这些文章讨论了如何操作画布中的像素。关于显示来自跨域服务器的图像,您不能使用canvas来执行此操作,您将得到安全异常。要从其他服务器加载图像,您可以使用自己的服务器作为代理,在您的服务器上调用具有完整图像路径的方法,您的服务器应该从其他服务器下载图像并将其发送回给您。这样您就可以显示来自其他域的图像。

Pixel Manipulation

check the above link. The articles discusses how you can manipulate pixels in a canvas. About displaying images from cross domain server, you cannot do so using canvas, you will get a security exception. To load the images from other server you can use your own server as a proxy, call a method at your server with complete image path and your server should download it image from other server and send it back to you. This way you can show the images from other domains.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文