Implement image display and complete screen and displayed image in variable canvas size. Add caching to image generation

This commit is contained in:
mmcwilliams 2024-08-17 21:22:17 -04:00
parent 9d27d59e29
commit 7b5a9ba3d2
18 changed files with 1135 additions and 48 deletions

View File

@ -9,9 +9,33 @@ class Display {
private canvas : HTMLCanvasElement;
private ctx : CanvasRenderingContext2D;
private screen : any;
private sequence : boolean = false;
private offsetX : number = 0;
private offsetY : number = 0;
private width : number = 0;
private height : number = 0;
private canvasScale : number = 0;
private canvasWidth : number = 0;
private canvasHeight : number = 0;
private canvasOffsetX : number = 0;
private canvasOffsetY : number = 0;
private screenWidth : number = 0;
private screenHeight : number = 0;
private screenOffsetX : number = 0;
private screenOffsetY : number = 0;
private displayWidth : number = 0;
private displayHeight : number = 0;
private displayOffsetX : number = 0;
private displayOffsetY : number = 0;
constructor () {
this.parentElement = document.getElementById('display') as HTMLUListElement;
this.create();
window.onresize = this.onResize.bind(this);
}
private create () {
this.canvas = this.parentElement.getElementsByTagName('canvas')[0];
@ -21,34 +45,90 @@ class Display {
height : parseInt((document.getElementById('height') as HTMLInputElement).value)
}
this.updateSize();
this.clear();
this.updateScreen();
this.updateDisplay();
}
private updateSize () {
const w : number = this.parentElement.clientWidth - 12;
const h : number = this.parentElement.clientHeight - 12;
const clientRatio : number = w / h;
const screenRatio : number = this.screen.width / this.screen.height;
let val : number;
let offset : number;
console.log(`${w},${h}`);
this.canvas.width = w;
this.canvas.height = h;
this.ctx.strokeStyle = "rgb(0, 0, 255)";
if (screenRatio > clientRatio) {
val = Math.floor(w / screenRatio);
offset = Math.round((h - val) / 2);
this.ctx.rect(0, offset + 1, w, val);
} else {
val = Math.round(h * screenRatio);
offset = Math.round((w - val) / 2);
this.ctx.rect(offset, 1, val, h - 1);
}
private updateSize () {
this.canvasScale = window.devicePixelRatio;
this.canvasWidth = this.parentElement.clientWidth - 12;
this.canvasHeight = this.parentElement.clientHeight - 12;
console.log(`${this.canvasWidth},${this.canvasHeight}`);
this.canvas.width = this.canvasWidth;
this.canvas.height = this.canvasHeight;
}
private clear () {
this.ctx.fillStyle = 'rgb(0, 0, 0)';
this.ctx.fillRect(0, 0, this.canvasWidth, this.canvasHeight);
}
private updateScreen () {
const clientRatio : number = this.canvasWidth / this.canvasHeight;
const screenRatio : number = this.screen.width / this.screen.height;
if (screenRatio > clientRatio) {
this.screenWidth = this.canvasWidth - 2;
this.screenHeight = Math.floor(this.canvasWidth / screenRatio);
this.screenOffsetX = 1;
this.screenOffsetY = Math.round((this.canvasHeight - this.screenHeight) / 2);
} else {
this.screenWidth = Math.round(this.canvasHeight * screenRatio);
this.screenHeight = this.canvasHeight - 2;
this.screenOffsetY = 1;
this.screenOffsetX = Math.round((this.canvasWidth - this.screenWidth) / 2);
}
this.ctx.strokeStyle = 'rgb(0, 0, 255)';
this.ctx.rect(this.screenOffsetX, this.screenOffsetY, this.screenWidth, this.screenHeight);
this.ctx.stroke();
}
private updateDisplay () {
if (!this.sequence) {
return;
}
console.log(this.sequence)
const screenScaleX : number = this.screenWidth / this.screen.width;
const screenScaleY : number = this.screenHeight / this.screen.height;
this.displayWidth = Math.round(this.width * screenScaleX);
this.displayHeight = Math.round(this.height * screenScaleY);
this.displayOffsetX = this.screenOffsetX + Math.round(this.offsetX * screenScaleX);
this.displayOffsetY = this.screenOffsetY + Math.round(this.offsetY * screenScaleY);
this.ctx.fillStyle = 'rgb(125, 125, 125)';
this.ctx.fillRect(this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
console.log(`${this.displayOffsetX}, ${this.displayOffsetY}, ${this.displayWidth}, ${this.displayHeight}`);
this.updateImage();
}
private updateImage() {
const img : any = new Image;
img.onload = function () {
this.ctx.drawImage(img, this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
}.bind(this);
img.src = `/${this.displayWidth}/${this.displayHeight}/image.jpg`;
}
public update (msg : Message) {
}
public set (state : State) {
this.sequence = true;
this.offsetX = state.offset.x;
this.offsetY = state.offset.y;
this.width = state.display.width;
this.height = state.display.height;
this.updateDisplay();
}
private onResize (event : any) {
this.updateSize();
this.clear();
this.updateScreen();
this.updateDisplay();
}
}
class Client {
@ -130,6 +210,7 @@ class Client {
private setDisplay (state : State) {
console.dir(state);
this.display.set(state);
}
private cmd (msg : Message) {

10
dist/image/index.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
/// <reference types="node" />
export declare class Image {
private thumbnailCache;
private thumbnailHash;
private blankCache;
private blankHash;
constructor();
thumbnail(path: string, width: number, height: number): Promise<Buffer>;
blank(width: number, height: number): Promise<Buffer>;
}

48
dist/image/index.js vendored Normal file
View File

@ -0,0 +1,48 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Image = void 0;
const sharp_1 = __importDefault(require("sharp"));
const hash_1 = require("../hash");
class Image {
constructor() {
this.thumbnailCache = null;
this.thumbnailHash = null;
this.blankCache = null;
this.blankHash = null;
}
async thumbnail(path, width, height) {
const hash = hash_1.Hashes.stringHash(`${path},${width},${height}`);
if (hash !== this.thumbnailHash) {
const options = {
width,
height,
fit: sharp_1.default.fit.fill
};
this.thumbnailCache = await (0, sharp_1.default)(path).resize(options).jpeg().toBuffer();
this.thumbnailHash = hash;
}
return this.thumbnailCache;
}
async blank(width, height) {
const hash = hash_1.Hashes.stringHash(`${width},${height}`);
if (hash !== this.blankHash) {
const options = {
create: {
width,
height,
channels: 3,
background: { r: 125, g: 125, b: 125 }
}
};
this.blankCache = await (0, sharp_1.default)(options).jpeg().toBuffer();
this.blankHash = hash;
}
return this.blankCache;
}
}
exports.Image = Image;
module.exports = { Image };
//# sourceMappingURL=index.js.map

1
dist/image/index.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/image/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,kCAAiC;AAEjC,MAAa,KAAK;IAKjB;QAJQ,mBAAc,G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GAAG,IAAI,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;CACD;AAtCD,sBAsCC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC"}

31
dist/index.js vendored
View File

@ -40,6 +40,7 @@ const ffmpeg_1 = require("./ffmpeg");
const ffprobe_1 = require("./ffprobe");
const camera_1 = require("./camera");
const sequence_1 = require("./sequence");
const image_1 = require("./image");
const log = (0, log_1.createLog)('fm');
const app = (0, express_1.default)();
let wss;
@ -47,6 +48,7 @@ let fd;
let display;
let ffmpeg;
let ffprobe;
let image;
let camera;
let sequence;
let index;
@ -233,13 +235,40 @@ app.get('/', async (req, res, next) => {
const html = index({ sequences: sequencesArr, width, height });
res.send(html);
});
app.get('/image.jpg', async (req, res, next) => {
app.get('/:width/:height/image.jpg', async (req, res, next) => {
let data;
let current = sequence.getCurrent();
let width = parseInt(req.params.width);
let height = parseInt(req.params.height);
if (current !== null) {
try {
data = await image.thumbnail(current.path, width, height);
log.info(`Image: ${current.path} - ${width},${height}`);
}
catch (err) {
log.error('Error getting thumbnail of ${current}', err);
return next(new Error('Error getting thumbnail'));
}
}
else {
try {
data = await image.blank(width, height);
log.info(`Blank - ${width},${height}`);
}
catch (err) {
log.error('Error generating blank image', err);
return next(new Error('Error generating blank image'));
}
}
res.contentType('image/jpeg');
res.send(data);
});
async function main() {
await settings();
index = await createTemplate('./views/index.hbs');
ffmpeg = new ffmpeg_1.FFMPEG(process.env['FFMPEG']);
ffprobe = new ffprobe_1.FFPROBE();
image = new image_1.Image();
camera = new camera_1.Camera();
display = new display_1.Display(width, height);
//fd = new FD(process.env['FD'], width, height, process.env['FD_HOST'], parseInt(process.env['FD_PORT']));

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import type { SequenceObject } from '../files';
import type { SequenceObject, ImageObject } from '../files';
import type { FD } from '../fd';
import type { Camera } from '../camera';
import type { Display } from '../display';
@ -36,6 +36,6 @@ export declare class Sequence {
getSequenceState(): SequenceState;
setExposure(ms: number): void;
getStatus(): SequenceStatus;
getCurrent(): string;
getCurrent(): ImageObject;
}
export {};

View File

@ -106,6 +106,9 @@ class Sequence {
};
}
getSequenceState() {
if (this.current === null) {
return null;
}
return {
hash: this.current.hash,
name: this.current.name,
@ -126,7 +129,7 @@ class Sequence {
}
getCurrent() {
if (this.current !== null && this.images.length > 0 && typeof this.images[this.frame] !== 'undefined') {
this.images[this.frame];
return this.images[this.frame];
}
return null;
}

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sequence/index.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AACjC,gCAAkC;AAQlC,IAAK,cAIJ;AAJD,WAAK,cAAc;IACjB,mDAAI,CAAA;IACJ,yDAAO,CAAA;IACP,uDAAM,CAAA;AACR,CAAC,EAJI,cAAc,KAAd,cAAc,QAIlB;AAED,MAAa,QAAQ;IAmBpB,YAAa,MAAe,EAAE,EAAO,EAAE,OAAgB,EAAE,OAAiB,EAAE,IAAe;QAjBnF,YAAO,GAAoB,IAAI,CAAC;QAChC,SAAI,GAAe,IAAI,CAAC;QACxB,WAAM,GAAmB,EAAE,CAAC;QAM5B,YAAO,GAAa,KAAK,CAAC;QAC1B,WAAM,GAAa,KAAK,CAAC;QAEzB,aAAQ,GAAY,CAAC,CAAC;QACtB,UAAK,GAAY,CAAC,CAAC;QACnB,WAAM,GAAY,CAAC,CAAC;QAEpB,aAAQ,GAAY,IAAI,CAAC;QAGhC,IAAI,CAAC,GAAG,GAAG,IAAA,eAAS,EAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IA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MAAM,CAAC;QAC9B,CAAC;aAAM,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACzC,OAAO,cAAc,CAAC,OAAO,CAAC;QAC/B,CAAC;QACD,OAAO,cAAc,CAAC,IAAI,CAAC;IAC5B,CAAC;IAEM,UAAU;QAChB,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE,CAAC;YACvG,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AApJD,4BAoJC"}

748
package-lock.json generated
View File

@ -18,6 +18,7 @@
"nodemailer": "^6.9.13",
"pureimage": "^0.4.13",
"serialport": "^12.0.0",
"sharp": "^0.33.4",
"sqlite3": "^5.1.7",
"triple-beam": "^1.4.1",
"uuid": "^9.0.1",
@ -53,12 +54,472 @@
"kuler": "^2.0.0"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.2.0.tgz",
"integrity": "sha512-bV21/9LQmcQeCPEg3BDFtvwL6cwiTMksYNWQQ4KOxCZikEGalWtenoZ0wCiukJINlGCIi2KXx01g4FoH/LxpzQ==",
"license": "MIT",
"optional": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@gar/promisify": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz",
"integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==",
"optional": true
},
"node_modules/@img/sharp-darwin-arm64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.4.tgz",
"integrity": "sha512-p0suNqXufJs9t3RqLBO6vvrgr5OhgbWp76s5gTRvdmxmuv9E1rcaqGUsl3l4mKVmXPkTkTErXediAui4x+8PSA==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"glibc": ">=2.26",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-darwin-arm64": "1.0.2"
}
},
"node_modules/@img/sharp-darwin-x64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.4.tgz",
"integrity": "sha512-0l7yRObwtTi82Z6ebVI2PnHT8EB2NxBgpK2MiKJZJ7cz32R4lxd001ecMhzzsZig3Yv9oclvqqdV93jo9hy+Dw==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"glibc": ">=2.26",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-darwin-x64": "1.0.2"
}
},
"node_modules/@img/sharp-libvips-darwin-arm64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.2.tgz",
"integrity": "sha512-tcK/41Rq8IKlSaKRCCAuuY3lDJjQnYIW1UXU1kxcEKrfL8WR7N6+rzNoOxoQRJWTAECuKwgAHnPvqXGN8XfkHA==",
"cpu": [
"arm64"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"darwin"
],
"engines": {
"macos": ">=11",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-darwin-x64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.2.tgz",
"integrity": "sha512-Ofw+7oaWa0HiiMiKWqqaZbaYV3/UGL2wAPeLuJTx+9cXpCRdvQhCLG0IH8YGwM0yGWGLpsF4Su9vM1o6aer+Fw==",
"cpu": [
"x64"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"darwin"
],
"engines": {
"macos": ">=10.13",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-linux-arm": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.2.tgz",
"integrity": "sha512-iLWCvrKgeFoglQxdEwzu1eQV04o8YeYGFXtfWU26Zr2wWT3q3MTzC+QTCO3ZQfWd3doKHT4Pm2kRmLbupT+sZw==",
"cpu": [
"arm"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"linux"
],
"engines": {
"glibc": ">=2.28",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-linux-arm64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.2.tgz",
"integrity": "sha512-x7kCt3N00ofFmmkkdshwj3vGPCnmiDh7Gwnd4nUwZln2YjqPxV1NlTyZOvoDWdKQVDL911487HOueBvrpflagw==",
"cpu": [
"arm64"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"linux"
],
"engines": {
"glibc": ">=2.26",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-linux-s390x": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.2.tgz",
"integrity": "sha512-cmhQ1J4qVhfmS6szYW7RT+gLJq9dH2i4maq+qyXayUSn9/3iY2ZeWpbAgSpSVbV2E1JUL2Gg7pwnYQ1h8rQIog==",
"cpu": [
"s390x"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"linux"
],
"engines": {
"glibc": ">=2.28",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-linux-x64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.2.tgz",
"integrity": "sha512-E441q4Qdb+7yuyiADVi5J+44x8ctlrqn8XgkDTwr4qPJzWkaHwD489iZ4nGDgcuya4iMN3ULV6NwbhRZJ9Z7SQ==",
"cpu": [
"x64"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"linux"
],
"engines": {
"glibc": ">=2.26",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-linuxmusl-arm64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.2.tgz",
"integrity": "sha512-3CAkndNpYUrlDqkCM5qhksfE+qSIREVpyoeHIU6jd48SJZViAmznoQQLAv4hVXF7xyUB9zf+G++e2v1ABjCbEQ==",
"cpu": [
"arm64"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"linux"
],
"engines": {
"musl": ">=1.2.2",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-linuxmusl-x64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.2.tgz",
"integrity": "sha512-VI94Q6khIHqHWNOh6LLdm9s2Ry4zdjWJwH56WoiJU7NTeDwyApdZZ8c+SADC8OH98KWNQXnE01UdJ9CSfZvwZw==",
"cpu": [
"x64"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"linux"
],
"engines": {
"musl": ">=1.2.2",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-linux-arm": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.4.tgz",
"integrity": "sha512-RUgBD1c0+gCYZGCCe6mMdTiOFS0Zc/XrN0fYd6hISIKcDUbAW5NtSQW9g/powkrXYm6Vzwd6y+fqmExDuCdHNQ==",
"cpu": [
"arm"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"glibc": ">=2.28",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-linux-arm": "1.0.2"
}
},
"node_modules/@img/sharp-linux-arm64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.4.tgz",
"integrity": "sha512-2800clwVg1ZQtxwSoTlHvtm9ObgAax7V6MTAB/hDT945Tfyy3hVkmiHpeLPCKYqYR1Gcmv1uDZ3a4OFwkdBL7Q==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"glibc": ">=2.26",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-linux-arm64": "1.0.2"
}
},
"node_modules/@img/sharp-linux-s390x": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.4.tgz",
"integrity": "sha512-h3RAL3siQoyzSoH36tUeS0PDmb5wINKGYzcLB5C6DIiAn2F3udeFAum+gj8IbA/82+8RGCTn7XW8WTFnqag4tQ==",
"cpu": [
"s390x"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"glibc": ">=2.31",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-linux-s390x": "1.0.2"
}
},
"node_modules/@img/sharp-linux-x64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.4.tgz",
"integrity": "sha512-GoR++s0XW9DGVi8SUGQ/U4AeIzLdNjHka6jidVwapQ/JebGVQIpi52OdyxCNVRE++n1FCLzjDovJNozif7w/Aw==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"glibc": ">=2.26",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-linux-x64": "1.0.2"
}
},
"node_modules/@img/sharp-linuxmusl-arm64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.4.tgz",
"integrity": "sha512-nhr1yC3BlVrKDTl6cO12gTpXMl4ITBUZieehFvMntlCXFzH2bvKG76tBL2Y/OqhupZt81pR7R+Q5YhJxW0rGgQ==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"musl": ">=1.2.2",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-linuxmusl-arm64": "1.0.2"
}
},
"node_modules/@img/sharp-linuxmusl-x64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.4.tgz",
"integrity": "sha512-uCPTku0zwqDmZEOi4ILyGdmW76tH7dm8kKlOIV1XC5cLyJ71ENAAqarOHQh0RLfpIpbV5KOpXzdU6XkJtS0daw==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"musl": ">=1.2.2",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-linuxmusl-x64": "1.0.2"
}
},
"node_modules/@img/sharp-wasm32": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.4.tgz",
"integrity": "sha512-Bmmauh4sXUsUqkleQahpdNXKvo+wa1V9KhT2pDA4VJGKwnKMJXiSTGphn0gnJrlooda0QxCtXc6RX1XAU6hMnQ==",
"cpu": [
"wasm32"
],
"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
"optional": true,
"dependencies": {
"@emnapi/runtime": "^1.1.1"
},
"engines": {
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-win32-ia32": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.4.tgz",
"integrity": "sha512-99SJ91XzUhYHbx7uhK3+9Lf7+LjwMGQZMDlO/E/YVJ7Nc3lyDFZPGhjwiYdctoH2BOzW9+TnfqcaMKt0jHLdqw==",
"cpu": [
"ia32"
],
"license": "Apache-2.0 AND LGPL-3.0-or-later",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-win32-x64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.4.tgz",
"integrity": "sha512-3QLocdTRVIrFNye5YocZl+KKpYKP+fksi1QhmOArgx7GyhIbQp/WrJRu176jm8IxromS7RIkzMiMINVdBtC8Aw==",
"cpu": [
"x64"
],
"license": "Apache-2.0 AND LGPL-3.0-or-later",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
"npm": ">=9.6.5",
"pnpm": ">=7.1.0",
"yarn": ">=3.2.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@npmcli/fs": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.1.1.tgz",
@ -2483,6 +2944,77 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
"node_modules/sharp": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.4.tgz",
"integrity": "sha512-7i/dt5kGl7qR4gwPRD2biwD2/SvBn3O04J77XKFgL2OnZtQw+AG9wnuS/csmu80nPRHLYE9E41fyEiG8nhH6/Q==",
"hasInstallScript": true,
"license": "Apache-2.0",
"dependencies": {
"color": "^4.2.3",
"detect-libc": "^2.0.3",
"semver": "^7.6.0"
},
"engines": {
"libvips": ">=8.15.2",
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-darwin-arm64": "0.33.4",
"@img/sharp-darwin-x64": "0.33.4",
"@img/sharp-libvips-darwin-arm64": "1.0.2",
"@img/sharp-libvips-darwin-x64": "1.0.2",
"@img/sharp-libvips-linux-arm": "1.0.2",
"@img/sharp-libvips-linux-arm64": "1.0.2",
"@img/sharp-libvips-linux-s390x": "1.0.2",
"@img/sharp-libvips-linux-x64": "1.0.2",
"@img/sharp-libvips-linuxmusl-arm64": "1.0.2",
"@img/sharp-libvips-linuxmusl-x64": "1.0.2",
"@img/sharp-linux-arm": "0.33.4",
"@img/sharp-linux-arm64": "0.33.4",
"@img/sharp-linux-s390x": "0.33.4",
"@img/sharp-linux-x64": "0.33.4",
"@img/sharp-linuxmusl-arm64": "0.33.4",
"@img/sharp-linuxmusl-x64": "0.33.4",
"@img/sharp-wasm32": "0.33.4",
"@img/sharp-win32-ia32": "0.33.4",
"@img/sharp-win32-x64": "0.33.4"
}
},
"node_modules/sharp/node_modules/color": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz",
"integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==",
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1",
"color-string": "^1.9.0"
},
"engines": {
"node": ">=12.5.0"
}
},
"node_modules/sharp/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/sharp/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT"
},
"node_modules/side-channel": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
@ -2809,6 +3341,13 @@
"node": ">= 14.0.0"
}
},
"node_modules/tslib": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz",
"integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==",
"license": "0BSD",
"optional": true
},
"node_modules/tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
@ -3045,12 +3584,162 @@
"kuler": "^2.0.0"
}
},
"@emnapi/runtime": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.2.0.tgz",
"integrity": "sha512-bV21/9LQmcQeCPEg3BDFtvwL6cwiTMksYNWQQ4KOxCZikEGalWtenoZ0wCiukJINlGCIi2KXx01g4FoH/LxpzQ==",
"optional": true,
"requires": {
"tslib": "^2.4.0"
}
},
"@gar/promisify": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz",
"integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==",
"optional": true
},
"@img/sharp-darwin-arm64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.4.tgz",
"integrity": "sha512-p0suNqXufJs9t3RqLBO6vvrgr5OhgbWp76s5gTRvdmxmuv9E1rcaqGUsl3l4mKVmXPkTkTErXediAui4x+8PSA==",
"optional": true,
"requires": {
"@img/sharp-libvips-darwin-arm64": "1.0.2"
}
},
"@img/sharp-darwin-x64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.4.tgz",
"integrity": "sha512-0l7yRObwtTi82Z6ebVI2PnHT8EB2NxBgpK2MiKJZJ7cz32R4lxd001ecMhzzsZig3Yv9oclvqqdV93jo9hy+Dw==",
"optional": true,
"requires": {
"@img/sharp-libvips-darwin-x64": "1.0.2"
}
},
"@img/sharp-libvips-darwin-arm64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.2.tgz",
"integrity": "sha512-tcK/41Rq8IKlSaKRCCAuuY3lDJjQnYIW1UXU1kxcEKrfL8WR7N6+rzNoOxoQRJWTAECuKwgAHnPvqXGN8XfkHA==",
"optional": true
},
"@img/sharp-libvips-darwin-x64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.2.tgz",
"integrity": "sha512-Ofw+7oaWa0HiiMiKWqqaZbaYV3/UGL2wAPeLuJTx+9cXpCRdvQhCLG0IH8YGwM0yGWGLpsF4Su9vM1o6aer+Fw==",
"optional": true
},
"@img/sharp-libvips-linux-arm": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.2.tgz",
"integrity": "sha512-iLWCvrKgeFoglQxdEwzu1eQV04o8YeYGFXtfWU26Zr2wWT3q3MTzC+QTCO3ZQfWd3doKHT4Pm2kRmLbupT+sZw==",
"optional": true
},
"@img/sharp-libvips-linux-arm64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.2.tgz",
"integrity": "sha512-x7kCt3N00ofFmmkkdshwj3vGPCnmiDh7Gwnd4nUwZln2YjqPxV1NlTyZOvoDWdKQVDL911487HOueBvrpflagw==",
"optional": true
},
"@img/sharp-libvips-linux-s390x": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.2.tgz",
"integrity": "sha512-cmhQ1J4qVhfmS6szYW7RT+gLJq9dH2i4maq+qyXayUSn9/3iY2ZeWpbAgSpSVbV2E1JUL2Gg7pwnYQ1h8rQIog==",
"optional": true
},
"@img/sharp-libvips-linux-x64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.2.tgz",
"integrity": "sha512-E441q4Qdb+7yuyiADVi5J+44x8ctlrqn8XgkDTwr4qPJzWkaHwD489iZ4nGDgcuya4iMN3ULV6NwbhRZJ9Z7SQ==",
"optional": true
},
"@img/sharp-libvips-linuxmusl-arm64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.2.tgz",
"integrity": "sha512-3CAkndNpYUrlDqkCM5qhksfE+qSIREVpyoeHIU6jd48SJZViAmznoQQLAv4hVXF7xyUB9zf+G++e2v1ABjCbEQ==",
"optional": true
},
"@img/sharp-libvips-linuxmusl-x64": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.2.tgz",
"integrity": "sha512-VI94Q6khIHqHWNOh6LLdm9s2Ry4zdjWJwH56WoiJU7NTeDwyApdZZ8c+SADC8OH98KWNQXnE01UdJ9CSfZvwZw==",
"optional": true
},
"@img/sharp-linux-arm": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.4.tgz",
"integrity": "sha512-RUgBD1c0+gCYZGCCe6mMdTiOFS0Zc/XrN0fYd6hISIKcDUbAW5NtSQW9g/powkrXYm6Vzwd6y+fqmExDuCdHNQ==",
"optional": true,
"requires": {
"@img/sharp-libvips-linux-arm": "1.0.2"
}
},
"@img/sharp-linux-arm64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.4.tgz",
"integrity": "sha512-2800clwVg1ZQtxwSoTlHvtm9ObgAax7V6MTAB/hDT945Tfyy3hVkmiHpeLPCKYqYR1Gcmv1uDZ3a4OFwkdBL7Q==",
"optional": true,
"requires": {
"@img/sharp-libvips-linux-arm64": "1.0.2"
}
},
"@img/sharp-linux-s390x": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.4.tgz",
"integrity": "sha512-h3RAL3siQoyzSoH36tUeS0PDmb5wINKGYzcLB5C6DIiAn2F3udeFAum+gj8IbA/82+8RGCTn7XW8WTFnqag4tQ==",
"optional": true,
"requires": {
"@img/sharp-libvips-linux-s390x": "1.0.2"
}
},
"@img/sharp-linux-x64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.4.tgz",
"integrity": "sha512-GoR++s0XW9DGVi8SUGQ/U4AeIzLdNjHka6jidVwapQ/JebGVQIpi52OdyxCNVRE++n1FCLzjDovJNozif7w/Aw==",
"optional": true,
"requires": {
"@img/sharp-libvips-linux-x64": "1.0.2"
}
},
"@img/sharp-linuxmusl-arm64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.4.tgz",
"integrity": "sha512-nhr1yC3BlVrKDTl6cO12gTpXMl4ITBUZieehFvMntlCXFzH2bvKG76tBL2Y/OqhupZt81pR7R+Q5YhJxW0rGgQ==",
"optional": true,
"requires": {
"@img/sharp-libvips-linuxmusl-arm64": "1.0.2"
}
},
"@img/sharp-linuxmusl-x64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.4.tgz",
"integrity": "sha512-uCPTku0zwqDmZEOi4ILyGdmW76tH7dm8kKlOIV1XC5cLyJ71ENAAqarOHQh0RLfpIpbV5KOpXzdU6XkJtS0daw==",
"optional": true,
"requires": {
"@img/sharp-libvips-linuxmusl-x64": "1.0.2"
}
},
"@img/sharp-wasm32": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.4.tgz",
"integrity": "sha512-Bmmauh4sXUsUqkleQahpdNXKvo+wa1V9KhT2pDA4VJGKwnKMJXiSTGphn0gnJrlooda0QxCtXc6RX1XAU6hMnQ==",
"optional": true,
"requires": {
"@emnapi/runtime": "^1.1.1"
}
},
"@img/sharp-win32-ia32": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.4.tgz",
"integrity": "sha512-99SJ91XzUhYHbx7uhK3+9Lf7+LjwMGQZMDlO/E/YVJ7Nc3lyDFZPGhjwiYdctoH2BOzW9+TnfqcaMKt0jHLdqw==",
"optional": true
},
"@img/sharp-win32-x64": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.4.tgz",
"integrity": "sha512-3QLocdTRVIrFNye5YocZl+KKpYKP+fksi1QhmOArgx7GyhIbQp/WrJRu176jm8IxromS7RIkzMiMINVdBtC8Aw==",
"optional": true
},
"@npmcli/fs": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.1.1.tgz",
@ -4883,6 +5572,59 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
"sharp": {
"version": "0.33.4",
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.4.tgz",
"integrity": "sha512-7i/dt5kGl7qR4gwPRD2biwD2/SvBn3O04J77XKFgL2OnZtQw+AG9wnuS/csmu80nPRHLYE9E41fyEiG8nhH6/Q==",
"requires": {
"@img/sharp-darwin-arm64": "0.33.4",
"@img/sharp-darwin-x64": "0.33.4",
"@img/sharp-libvips-darwin-arm64": "1.0.2",
"@img/sharp-libvips-darwin-x64": "1.0.2",
"@img/sharp-libvips-linux-arm": "1.0.2",
"@img/sharp-libvips-linux-arm64": "1.0.2",
"@img/sharp-libvips-linux-s390x": "1.0.2",
"@img/sharp-libvips-linux-x64": "1.0.2",
"@img/sharp-libvips-linuxmusl-arm64": "1.0.2",
"@img/sharp-libvips-linuxmusl-x64": "1.0.2",
"@img/sharp-linux-arm": "0.33.4",
"@img/sharp-linux-arm64": "0.33.4",
"@img/sharp-linux-s390x": "0.33.4",
"@img/sharp-linux-x64": "0.33.4",
"@img/sharp-linuxmusl-arm64": "0.33.4",
"@img/sharp-linuxmusl-x64": "0.33.4",
"@img/sharp-wasm32": "0.33.4",
"@img/sharp-win32-ia32": "0.33.4",
"@img/sharp-win32-x64": "0.33.4",
"color": "^4.2.3",
"detect-libc": "^2.0.3",
"semver": "^7.6.0"
},
"dependencies": {
"color": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz",
"integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==",
"requires": {
"color-convert": "^2.0.1",
"color-string": "^1.9.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
}
}
},
"side-channel": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
@ -5112,6 +5854,12 @@
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz",
"integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg=="
},
"tslib": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz",
"integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==",
"optional": true
},
"tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",

View File

@ -31,6 +31,7 @@
"nodemailer": "^6.9.13",
"pureimage": "^0.4.13",
"serialport": "^12.0.0",
"sharp": "^0.33.4",
"sqlite3": "^5.1.7",
"triple-beam": "^1.4.1",
"uuid": "^9.0.1",

45
src/image/index.ts Normal file
View File

@ -0,0 +1,45 @@
import sharp from 'sharp';
import type { SharpOptions, ResizeOptions } from 'sharp';
import { Hashes } from '../hash';
export class Image {
private thumbnailCache : Buffer = null;
private thumbnailHash : string = null;
private blankCache : Buffer = null;
private blankHash : string = null;
constructor () {
}
public async thumbnail (path : string, width : number, height: number) : Promise<Buffer>{
const hash : string = Hashes.stringHash(`${path},${width},${height}`);
if (hash !== this.thumbnailHash) {
const options : ResizeOptions = {
width,
height,
fit: sharp.fit.fill
}
this.thumbnailCache = await sharp(path).resize(options).jpeg().toBuffer();
this.thumbnailHash = hash;
}
return this.thumbnailCache;
}
public async blank (width : number, height : number) {
const hash : string = Hashes.stringHash(`${width},${height}`);
if (hash !== this.blankHash) {
const options : SharpOptions = {
create: {
width,
height,
channels: 3,
background: { r: 125, g: 125, b: 125 }
}
};
this.blankCache = await sharp(options).jpeg().toBuffer();
this.blankHash = hash;
}
return this.blankCache;
}
}
module.exports = { Image };

View File

@ -17,7 +17,7 @@ import type { WebSocket } from 'ws';
import { createLog } from './log'
import { sendMail } from './mail';
import { Files } from './files';
import type { SequenceObject, VideoObject } from './files';
import type { SequenceObject, VideoObject, ImageObject } from './files';
import { Shell } from './shell';
import { delay } from './delay';
import { TestImage } from './testimage';
@ -27,6 +27,7 @@ import { FFMPEG } from './ffmpeg';
import { FFPROBE } from './ffprobe';
import { Camera } from './camera';
import { Sequence } from './sequence';
import { Image } from './image';
const log : Logger = createLog('fm');
const app : Express = express();
@ -35,6 +36,7 @@ let fd : FD;
let display : Display;
let ffmpeg : FFMPEG;
let ffprobe : FFPROBE;
let image : Image;
let camera : Camera;
let sequence : Sequence;
let index : HandlebarsTemplateDelegate<any>;
@ -229,8 +231,30 @@ app.get('/', async (req : Request, res : Response, next : NextFunction) => {
res.send(html);
});
app.get('/image.jpg', async (req : Request, res : Response, next : NextFunction) => {
app.get('/:width/:height/image.jpg', async (req : Request, res : Response, next : NextFunction) => {
let data : Buffer;
let current : ImageObject = sequence.getCurrent();
let width : number = parseInt(req.params.width);
let height : number = parseInt(req.params.height);
if (current !== null) {
try {
data = await image.thumbnail(current.path, width, height);
log.info(`Image: ${current.path} - ${width},${height}`);
} catch (err) {
log.error('Error getting thumbnail of ${current}', err);
return next(new Error('Error getting thumbnail'));
}
} else {
try {
data = await image.blank(width, height);
log.info(`Blank - ${width},${height}`);
} catch (err) {
log.error('Error generating blank image', err);
return next(new Error('Error generating blank image'));
}
}
res.contentType('image/jpeg');
res.send(data);
});
async function main () {
@ -238,6 +262,7 @@ async function main () {
index = await createTemplate('./views/index.hbs');
ffmpeg = new FFMPEG(process.env['FFMPEG']);
ffprobe = new FFPROBE();
image = new Image();
camera = new Camera();
display = new Display(width, height);
//fd = new FD(process.env['FD'], width, height, process.env['FD_HOST'], parseInt(process.env['FD_PORT']));

View File

@ -132,6 +132,9 @@ export class Sequence {
}
public getSequenceState () : SequenceState {
if (this.current === null) {
return null;
}
return {
hash : this.current.hash,
name : this.current.name,
@ -152,9 +155,9 @@ export class Sequence {
return SequenceStatus.IDLE;
}
public getCurrent () : string {
public getCurrent () : ImageObject {
if (this.current !== null && this.images.length > 0 && typeof this.images[this.frame] !== 'undefined') {
this.images[this.frame]
return this.images[this.frame]
}
return null;
}

View File

@ -32,6 +32,7 @@ html, body{
#display{
background: black;
min-height: 50vh;
max-height: 50vh;
}
#screen .field-row{

24
static/js/index.d.ts vendored
View File

@ -8,10 +8,34 @@ declare class Display {
private canvas;
private ctx;
private screen;
private sequence;
private offsetX;
private offsetY;
private width;
private height;
private canvasScale;
private canvasWidth;
private canvasHeight;
private canvasOffsetX;
private canvasOffsetY;
private screenWidth;
private screenHeight;
private screenOffsetX;
private screenOffsetY;
private displayWidth;
private displayHeight;
private displayOffsetX;
private displayOffsetY;
constructor();
private create;
private updateSize;
private clear;
private updateScreen;
private updateDisplay;
private updateImage;
update(msg: Message): void;
set(state: State): void;
private onResize;
}
declare class Client {
private display;

View File

@ -6,8 +6,27 @@ var SequenceStatus;
})(SequenceStatus || (SequenceStatus = {}));
class Display {
constructor() {
this.sequence = false;
this.offsetX = 0;
this.offsetY = 0;
this.width = 0;
this.height = 0;
this.canvasScale = 0;
this.canvasWidth = 0;
this.canvasHeight = 0;
this.canvasOffsetX = 0;
this.canvasOffsetY = 0;
this.screenWidth = 0;
this.screenHeight = 0;
this.screenOffsetX = 0;
this.screenOffsetY = 0;
this.displayWidth = 0;
this.displayHeight = 0;
this.displayOffsetX = 0;
this.displayOffsetY = 0;
this.parentElement = document.getElementById('display');
this.create();
window.onresize = this.onResize.bind(this);
}
create() {
this.canvas = this.parentElement.getElementsByTagName('canvas')[0];
@ -17,32 +36,80 @@ class Display {
height: parseInt(document.getElementById('height').value)
};
this.updateSize();
this.clear();
this.updateScreen();
this.updateDisplay();
}
updateSize() {
const w = this.parentElement.clientWidth - 12;
const h = this.parentElement.clientHeight - 12;
const clientRatio = w / h;
this.canvasScale = window.devicePixelRatio;
this.canvasWidth = this.parentElement.clientWidth - 12;
this.canvasHeight = this.parentElement.clientHeight - 12;
console.log(`${this.canvasWidth},${this.canvasHeight}`);
this.canvas.width = this.canvasWidth;
this.canvas.height = this.canvasHeight;
}
clear() {
this.ctx.fillStyle = 'rgb(0, 0, 0)';
this.ctx.fillRect(0, 0, this.canvasWidth, this.canvasHeight);
}
updateScreen() {
const clientRatio = this.canvasWidth / this.canvasHeight;
const screenRatio = this.screen.width / this.screen.height;
let val;
let offset;
console.log(`${w},${h}`);
this.canvas.width = w;
this.canvas.height = h;
this.ctx.strokeStyle = "rgb(0, 0, 255)";
if (screenRatio > clientRatio) {
val = Math.floor(w / screenRatio);
offset = Math.round((h - val) / 2);
this.ctx.rect(0, offset + 1, w, val);
this.screenWidth = this.canvasWidth - 2;
this.screenHeight = Math.floor(this.canvasWidth / screenRatio);
this.screenOffsetX = 1;
this.screenOffsetY = Math.round((this.canvasHeight - this.screenHeight) / 2);
}
else {
val = Math.round(h * screenRatio);
offset = Math.round((w - val) / 2);
this.ctx.rect(offset, 1, val, h - 1);
this.screenWidth = Math.round(this.canvasHeight * screenRatio);
this.screenHeight = this.canvasHeight - 2;
this.screenOffsetY = 1;
this.screenOffsetX = Math.round((this.canvasWidth - this.screenWidth) / 2);
}
this.ctx.strokeStyle = 'rgb(0, 0, 255)';
this.ctx.rect(this.screenOffsetX, this.screenOffsetY, this.screenWidth, this.screenHeight);
this.ctx.stroke();
}
updateDisplay() {
if (!this.sequence) {
return;
}
console.log(this.sequence);
const screenScaleX = this.screenWidth / this.screen.width;
const screenScaleY = this.screenHeight / this.screen.height;
this.displayWidth = Math.round(this.width * screenScaleX);
this.displayHeight = Math.round(this.height * screenScaleY);
this.displayOffsetX = this.screenOffsetX + Math.round(this.offsetX * screenScaleX);
this.displayOffsetY = this.screenOffsetY + Math.round(this.offsetY * screenScaleY);
this.ctx.fillStyle = 'rgb(125, 125, 125)';
this.ctx.fillRect(this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
console.log(`${this.displayOffsetX}, ${this.displayOffsetY}, ${this.displayWidth}, ${this.displayHeight}`);
this.updateImage();
}
updateImage() {
const img = new Image;
img.onload = function () {
this.ctx.drawImage(img, this.displayOffsetX, this.displayOffsetY, this.displayWidth, this.displayHeight);
}.bind(this);
img.src = `/${this.displayWidth}/${this.displayHeight}/image.jpg`;
}
update(msg) {
}
set(state) {
this.sequence = true;
this.offsetX = state.offset.x;
this.offsetY = state.offset.y;
this.width = state.display.width;
this.height = state.display.height;
this.updateDisplay();
}
onResize(event) {
this.updateSize();
this.clear();
this.updateScreen();
this.updateDisplay();
}
}
class Client {
constructor() {
@ -112,6 +179,7 @@ class Client {
}
setDisplay(state) {
console.dir(state);
this.display.set(state);
}
cmd(msg) {
switch (msg.cmd) {

File diff suppressed because one or more lines are too long