"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWorldIcon = exports.isPackIcon = exports.parseImageMetadata = void 0;
const exifr_1 = require("exifr");
const StorageUtilities_1 = require("./StorageUtilities");
/*
  Parses an image file, returning an any object with various metadata such as width and height

  available data is based on image format, see Exifr docs for info
*/
async function parseImageMetadata(file) {
    try {
        await file.loadContent();
        const imageReader = new exifr_1.Exifr();
        const fileData = StorageUtilities_1.default.getContentsAsBinary(file);
        if (!fileData) {
            return null;
        }
        return await imageReader.read(fileData).then(() => imageReader.parse());
    }
    catch (error) {
        console.error(error);
        return null;
    }
}
exports.parseImageMetadata = parseImageMetadata;
function isPackIcon(file) {
    return !!file && file.name.includes("pack_icon") && file.name.endsWith(".png");
}
exports.isPackIcon = isPackIcon;
function isWorldIcon(file) {
    return !!file && file.name.includes("world_icon") && file.name.endsWith(".jpeg");
}
exports.isWorldIcon = isWorldIcon;

//# sourceMappingURL=../maps/storage/ImageUtilites.js.map
