mirror of
https://github.com/usetrmnl/byos_node_lite.git
synced 2026-08-13 23:18:18 -07:00
Changed image greyscaling library from sharp to jimp
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 158 KiB |
Generated
+848
-118
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -8,11 +8,11 @@
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"express": "^5.1.0",
|
||||
"jimp": "^1.6.0",
|
||||
"liquidjs": "^10.21.1",
|
||||
"puppeteer": "^24.9.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"sharp": "^0.34.1",
|
||||
"tsx": "^4.19.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
+12
-5
@@ -1,10 +1,17 @@
|
||||
import sharp from "sharp";
|
||||
import {Jimp} from "jimp";
|
||||
|
||||
|
||||
export async function PNGto1BIT(image: Buffer) {
|
||||
const data = await sharp(image)
|
||||
.grayscale()
|
||||
.raw()
|
||||
.toBuffer();
|
||||
// Convert to grayscale
|
||||
const jimpImage = await Jimp.read(image);
|
||||
jimpImage.greyscale();
|
||||
const bit4Data = new Uint8Array(jimpImage.bitmap.data);
|
||||
|
||||
// Convert to 1-bit
|
||||
let data = new Uint8Array(jimpImage.bitmap.width * jimpImage.bitmap.height);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
data[i] = bit4Data[i * 4];
|
||||
}
|
||||
|
||||
// Fixed dimensions to match the device requirements
|
||||
const DISPLAY_BMP_IMAGE_SIZE = 48062;
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function App(data: TemplateDataType) {
|
||||
<HackerNews style={{width: '100%', height: '100%'}}/>
|
||||
</div>
|
||||
<div style={{width: '50%', overflow: 'hidden'}}>
|
||||
<img style={{height: '100%', marginLeft: '-160px'}} src='/assets/images/wallpaper.jpeg'/>
|
||||
<img style={{height: '80%', marginLeft: '-50px', marginTop: '10%'}} src='/assets/images/color.jpg'/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user