gpt4 book ai didi

javascript - 卡曼 : Could not find image or canvas for initialization

转载 作者:行者123 更新时间:2023-11-28 06:59:29 25 4
gpt4 key购买 nike

我尝试使用CamanJS用于图像处理。我有以下 html 文件:

<div class="filter-container modal">
<div class="filter">
<div class="filter-img"></div>
</div>
</div>

创建<img>我在我的 filter.js 中执行以下操作:

initialize: function (options) {
var self = this;

self.options = options;
self.promise = $q.defer();

self.loadImage().then(function (elem) {
self.imgWidth = elem.naturalWidth;
self.imgHeight = elem.naturalHeight;
self.imgOriginal = elem.cloneNode();
self.imgFilter = elem.cloneNode();

self.options.modal.el.querySelector(".filter-img").appendChild(self.imgFilter);
});

self.options.cancel = this.cancel.bind(this);
self.options.filter = this.filter.bind(this);
self.options.previousFilter = this.previousFilter.bind(this);
self.options.nextFilter = this.nextFilter.bind(this);
},

loadImage: function () {
var promise = $q.defer();

angular.element("<img />")
.bind("load", function (e) {
promise.resolve(this);
})
.bind("error", promise.reject)
.prop("src", this.options.url)
.prop("id", IMAGE_ID);

return promise.promise;
},

当我现在想测试过滤器时:

performFilter: function () {
Caman(IMAGE_ID, function () {
this.brightness(10);
this.contrast(30);
this.sepia(60);
this.saturation(-30);
this.render();
});
}

我收到错误消息:

Could not find image or canvas for initialization.

所以对我来说这意味着 <img>我创建的不存在?我不知道为什么。

最佳答案

交换此行:

Caman(IMAGE_ID, function() {

用这一行:

Caman(this.imgFilter, function() {

关于javascript - 卡曼 : Could not find image or canvas for initialization,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32287814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com