Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!Utils.isJsonFile(file)) {
switch (type.toLowerCase()) {
// if it's an image, get the width and height and add to the annotation body and canvas
case ExternalResourceType.IMAGE :
const image: any = await Jimp.read(file);
const width: number = image.bitmap.width;
const height: number = image.bitmap.height;
canvasJson.width = Math.max(canvasJson.width || 0, width);
canvasJson.height = Math.max(canvasJson.height || 0, height);
annotationJson.body.width = width;
annotationJson.body.height = height;
break;
// if it's a sound, get the duration and add to the canvas
case ExternalResourceType.SOUND :
case ExternalResourceType.VIDEO :
try {
const info: any = await ffprobe(file, { path: ffprobeStatic.path });
if (info && info.streams && info.streams.length) {
const duration: number = Number(info.streams[0].duration);
canvasJson.duration = duration;
}
} catch {
console.warn(`ffprobe couldn't load ${file}`);
}
break;
}
}
}