face-api/build/dom/fetchImage.js

11 lines
466 B
JavaScript
Raw Normal View History

2020-08-31 15:12:04 +02:00
import { bufferToImage } from './bufferToImage';
import { fetchOrThrow } from './fetchOrThrow';
export async function fetchImage(uri) {
const res = await fetchOrThrow(uri);
const blob = await (res).blob();
if (!blob.type.startsWith('image/')) {
throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${blob.type}, for url: ${res.url}`);
}
return bufferToImage(blob);
}
//# sourceMappingURL=fetchImage.js.map