Skip to content

Commit

Permalink
Replace jimp with image-js to fix issues with fs
Browse files Browse the repository at this point in the history
  • Loading branch information
zusorio committed Feb 9, 2023
1 parent 7777540 commit e3cb4d4
Show file tree
Hide file tree
Showing 4 changed files with 433 additions and 526 deletions.
6 changes: 3 additions & 3 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"bootstrap-vue": "^2.23.1",
"howler": "^2.2.3",
"jimp": "^0.16.1",
"image-js": "^0.35.3",
"marked": "^2.1.3",
"notyf": "^3.10.0",
"obs-websocket-js": "^5.0.2",
Expand All @@ -33,13 +33,13 @@
},
"devDependencies": {
"@vitejs/plugin-vue2": "^2.2.0",
"vite": "^4.1.1",
"@vue/eslint-config-standard": "^5.1.2",
"eslint": "^7.23.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2"
"eslint-plugin-vue": "^6.2.2",
"vite": "^4.1.1"
}
}
13 changes: 5 additions & 8 deletions website/src/components/broadcast/RecoloredHero.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</template>

<script>
import Jimp from "jimp/es";
import { Image } from "image-js";
import { heroRecolorColors } from "@/utils/theme-styles";
import { bg, resizedAttachment } from "@/utils/images";
Expand All @@ -28,12 +28,9 @@ function deHex(hexString) {
async function recolorImage(imageURL, toColor, fromColor) {
const [from, to] = [fromColor, toColor].map(deHex);
const image = await Jimp.read({
url: imageURL
});
const image = await Image.load(imageURL);
// console.log("image width", image.bitmap.width);
const frame = image.bitmap.data;
const frame = image.data;
const outputFrame = new Uint8Array(frame);// (new Uint8Array(frame)).slice(0, image.bitmap.width * image.bitmap.height * 4);
Expand All @@ -53,10 +50,10 @@ async function recolorImage(imageURL, toColor, fromColor) {
// console.log("output is", frame.length, outputFrame.length);
return {
pixels: {
...image.bitmap,
...image,
data: outputFrame
},
width: image.bitmap.width
width: image.width
};
}
Expand Down
3 changes: 1 addition & 2 deletions website/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
fs: require.resolve("rollup-plugin-node-builtins")
"@": fileURLToPath(new URL("./src", import.meta.url))
},
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"]
}
Expand Down
Loading

0 comments on commit e3cb4d4

Please sign in to comment.