Bildressource in imageDataFromFile mit try/finally freigeben
Stelle sicher, dass bitmap.close() auch bei Fehler aufgerufen wird. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -67,8 +67,11 @@ export function grabFrame(videoElement, maxEdge = 1280) {
|
||||
/** Ersatzweg ohne Kamera: Bilddatei auswaehlen (z. B. am Rechner). */
|
||||
export async function imageDataFromFile(file, maxEdge = 1280) {
|
||||
const bitmap = await createImageBitmap(file);
|
||||
try {
|
||||
assertHasSize(bitmap.width, bitmap.height);
|
||||
const data = drawScaled(bitmap, bitmap.width, bitmap.height, maxEdge);
|
||||
bitmap.close();
|
||||
return data;
|
||||
} finally {
|
||||
bitmap.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user