@blueharford/scrypted-spatial-awareness 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.nodejs.js +1 -1
- package/dist/main.nodejs.js.map +1 -1
- package/dist/plugin.zip +0 -0
- package/out/main.nodejs.js +36 -51
- package/out/main.nodejs.js.map +1 -1
- package/out/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/core/spatial-reasoning.ts +36 -20
package/out/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -86,38 +86,54 @@ export async function mediaObjectToBase64(mediaObject: MediaObject): Promise<Ima
|
|
|
86
86
|
try {
|
|
87
87
|
console.log(`[Image] Converting MediaObject, mimeType=${mediaObject?.mimeType}`);
|
|
88
88
|
|
|
89
|
-
//
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
// First convert to JPEG to ensure consistent format
|
|
90
|
+
const jpegMediaObject = await mediaManager.convertMediaObject(mediaObject, 'image/jpeg') as MediaObject;
|
|
91
|
+
console.log(`[Image] Converted to JPEG MediaObject`);
|
|
92
|
+
|
|
93
|
+
// Get the buffer from the converted media object
|
|
94
|
+
const buffer = await mediaManager.convertMediaObjectToBuffer(jpegMediaObject, 'image/jpeg');
|
|
95
|
+
|
|
96
|
+
// Check if we got an actual Buffer (not a proxy)
|
|
97
|
+
const isRealBuffer = Buffer.isBuffer(buffer);
|
|
98
|
+
const bufferLength = isRealBuffer ? buffer.length : 0;
|
|
99
|
+
|
|
100
|
+
console.log(`[Image] Buffer: isBuffer=${isRealBuffer}, length=${bufferLength}`);
|
|
101
|
+
|
|
102
|
+
if (!isRealBuffer || bufferLength === 0) {
|
|
103
|
+
console.warn('[Image] Did not receive a valid Buffer');
|
|
104
|
+
|
|
105
|
+
// Try alternate approach: get raw data using any type
|
|
106
|
+
try {
|
|
107
|
+
const anyMedia = mediaObject as any;
|
|
108
|
+
if (typeof anyMedia.getData === 'function') {
|
|
109
|
+
const data = await anyMedia.getData();
|
|
110
|
+
if (data && Buffer.isBuffer(data)) {
|
|
111
|
+
console.log(`[Image] Got data from getData(): ${data.length} bytes`);
|
|
112
|
+
if (data.length > 1000) {
|
|
113
|
+
const base64 = data.toString('base64');
|
|
114
|
+
return { base64, mediaType: 'image/jpeg' };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} catch (dataErr) {
|
|
119
|
+
console.warn('[Image] getData() failed:', dataErr);
|
|
120
|
+
}
|
|
98
121
|
|
|
99
|
-
if (buffer.length === 0) {
|
|
100
|
-
console.warn('[Image] Buffer is empty (0 bytes)');
|
|
101
122
|
return null;
|
|
102
123
|
}
|
|
103
124
|
|
|
104
125
|
// Check if buffer is too small to be a valid image (< 1KB is suspicious)
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
const bufferContent = buffer.toString('utf8').substring(0, 100);
|
|
108
|
-
console.warn(`[Image] Buffer too small (${buffer.length} bytes), content: ${bufferContent}`);
|
|
126
|
+
if (bufferLength < 1000) {
|
|
127
|
+
console.warn(`[Image] Buffer too small: ${bufferLength} bytes`);
|
|
109
128
|
return null;
|
|
110
129
|
}
|
|
111
130
|
|
|
112
131
|
// Convert buffer to base64 (raw, no data URL prefix)
|
|
113
132
|
const base64 = buffer.toString('base64');
|
|
114
133
|
|
|
115
|
-
|
|
116
|
-
const mediaType = mediaObject.mimeType?.split(';')[0] || 'image/jpeg';
|
|
117
|
-
|
|
118
|
-
console.log(`[Image] Converted to base64: ${base64.length} chars, type=${mediaType}`);
|
|
134
|
+
console.log(`[Image] Converted to base64: ${base64.length} chars`);
|
|
119
135
|
|
|
120
|
-
return { base64, mediaType };
|
|
136
|
+
return { base64, mediaType: 'image/jpeg' };
|
|
121
137
|
} catch (e) {
|
|
122
138
|
console.warn('[Image] Failed to convert MediaObject to base64:', e);
|
|
123
139
|
return null;
|