You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tried to implement a simple background removal in vuejs:
<template>
<divclass="w-full h-full">
<canvasref="canvas"></canvas>
<button@click="uploadImage">Upload Image</button>
<inputtype="file"ref="fileInput"@change="handleFileChange"style="display: none"accept="image/*"
/>
</div>
</template>
<script>
importremoveBackgroundfrom'@imgly/background-removal';exportdefault { name:"TextCanvas", methods: {uploadImage() {this.$refs.fileInput.click(); },asynchandleFileChange(event) {constfile=event.target.files[0];if (file) {constimageUrl=URL.createObjectURL(file);awaitthis.processImage(imageUrl); } },asyncprocessImage(imageUrl) {constimage=newImage();image.src= imageUrl;image.onload=async () => {constcanvas=this.$refs.canvas;constctx=canvas.getContext("2d");canvas.width=image.width;canvas.height=image.height;ctx.drawImage(image, 0, 0);awaitthis.removeImageBackground(); }; },asyncremoveImageBackground() {constcanvas=this.$refs.canvas;constctx=this.$refs.canvas.getContext('2d');constimageData=ctx.getImageData(0, 0, canvas.width, canvas.height);removeBackground(imageData).then((blob) => {// The result is a blob encoded as PNG. It can be converted to an URL to be used as HTMLImage.srcconsturl=URL.createObjectURL(blob);console.log(url); }) }, },mounted() { },};
</script>
However I kept getting error:
(0 , imgly_background_removal__WEBPACK_IMPORTED_MODULE_0_.default) is not a function
TypeError: (0 , imgly_background_removal__WEBPACK_IMPORTED_MODULE_0_.default) is not a function
at Proxy.removeImageBackground (webpack-internal:///./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/TextCanvas.vue?vue&type=script&lang=js:38:76)
at image.onload (webpack-internal:///./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/TextCanvas.vue?vue&type=script&lang=js:30:20)
Tried to implement a simple background removal in vuejs:
However I kept getting error:
(0 , imgly_background_removal__WEBPACK_IMPORTED_MODULE_0_.default) is not a function
TypeError: (0 , imgly_background_removal__WEBPACK_IMPORTED_MODULE_0_.default) is not a function
at Proxy.removeImageBackground (webpack-internal:///./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/TextCanvas.vue?vue&type=script&lang=js:38:76)
at image.onload (webpack-internal:///./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/TextCanvas.vue?vue&type=script&lang=js:30:20)
I also tried to replace the call to imglyRemoveBackground according to https://www.npmjs.com/package/@imgly/background-removal
I'm not sure why and I haven't seen any vuejs example with this package.
The text was updated successfully, but these errors were encountered: