face-api/build/dom/fetchImage.js

15 lines
635 B
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchImage = void 0;
const bufferToImage_1 = require("./bufferToImage");
const fetchOrThrow_1 = require("./fetchOrThrow");
async function fetchImage(uri) {
const res = await fetchOrThrow_1.fetchOrThrow(uri);
2020-08-18 14:04:33 +02:00
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_1.bufferToImage(blob);
2020-08-18 14:04:33 +02:00
}
exports.fetchImage = fetchImage;
2020-08-18 14:04:33 +02:00
//# sourceMappingURL=fetchImage.js.map