Pixastic 对我来说无法正常工作,为什么?

发布于 2024-10-27 10:52:34 字数 599 浏览 1 评论 0 原文

我需要在网页上进行一些交互式图像处理。我发现 pixastic ,它似乎很适合这项工作。

此页面上,我正在尝试模糊图像,但我只能得到“blurfast”去工作。 “模糊”对我不起作用。

我一直在环顾四周并阅读文档,但不明白为什么它会失败。有人有什么想法吗?

我用这个js:

$(function(){
    var img = document.getElementById("imageone");

    $("#blurfastbutton").click(function() {
        Pixastic.process(img, "blurfast", {amount:0.2});
    });

    $("#blurbutton").click(function() {
        Pixastic.process(img, "blur");
    });
});

I need to do some interactive image processing on a webpage. I found pixastic and it seemed good for the job.

On this page I'm trying do blur an image, but I can only get "blurfast" to work. "blur" doesn't work for me.

I've been looking around and reading the documentation and can't see why it fails. Has anyone any idea?

I use this js:

$(function(){
    var img = document.getElementById("imageone");

    $("#blurfastbutton").click(function() {
        Pixastic.process(img, "blurfast", {amount:0.2});
    });

    $("#blurbutton").click(function() {
        Pixastic.process(img, "blur");
    });
});

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

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

发布评论

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

评论(1

舞袖。长 2024-11-03 10:52:34

对于许多操作,Pixastic 必须将 元素与 元素交换,并执行每像素调整。使用“blur”操作图像时会引发安全异常,因为图像源驻留在与文档不同的域中。

您还应该注意,由于 canvas 元素的安全限制,Pixastic 只能处理与您使用它的页面位于同一主机上的图像。 [来源]

“blurfast”不会发生这种情况的原因< /code> 是因为它的工作方式不同:一遍又一遍地以非常小的量调整图像大小。显然,这并不违反 安全策略”。

最好的方法是坚持使用“blurfast”——毕竟它更快、更动态。如果您确实想使用“blur”,那么您必须确保所有图像与当前文档位于同一域中。

For many manipulations, Pixastic has to swap the <img> element with a <canvas> element and perform per-pixel adjustments. A security exception is being thrown when the image is being manipulated using "blur", because the image source resides on different domain to the document.

You should also be aware that, due to security restrictions in the canvas element, Pixastic will only work with images that reside on the same host as the page you're using it on. [source]

The reason this doesn't happen with "blurfast" is because it works differently: resizing the image over and over again by very small amounts. This, apparently, doesn't violate the security policies of the <canvas> element.

The best approach is to stick to "blurfast" — it is faster and more dynamic, after all. If you really want to use "blur" then you'll have to ensure that all images are on the same domain as the current document.

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