MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / onLoad

Method onLoad

yvlu/yvlu.ts:508–532  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

506 throw new Error("Invalid WebP file: too short");
507 }
508
509 // 检查RIFF头
510 if (imageBuffer.toString("ascii", 0, 4) !== "RIFF") {
511 throw new Error("Invalid WebP file: missing RIFF header");
512 }
513
514 // 检查WEBP标识
515 if (imageBuffer.toString("ascii", 8, 12) !== "WEBP") {
516 throw new Error("Invalid WebP file: missing WEBP signature");
517 }
518
519 // 读取VP8或VP8L头
520 const chunkHeader = imageBuffer.toString("ascii", 12, 16);
521
522 if (chunkHeader === "VP8 ") {
523 // VP8格式
524 const width = imageBuffer.readUInt16LE(26) & 0x3fff;
525 const height = imageBuffer.readUInt16LE(28) & 0x3fff;
526 return { width, height };
527 } else if (chunkHeader === "VP8L") {
528 // VP8L格式
529 const data = imageBuffer.readUInt32LE(21);
530 const width = (data & 0x3fff) + 1;
531 const height = ((data >> 14) & 0x3fff) + 1;
532 return { width, height };
533 } else if (chunkHeader === "VP8X") {
534 // VP8X格式
535 const width = (imageBuffer.readUInt32LE(24) & 0xffffff) + 1;

Callers

nothing calls this directly

Calls 1

loadConfigMethod · 0.95

Tested by

no test coverage detected