import { IMAGE_MAGICK_FORMAT, } from '../../../../code/type/index.js';
import { buildCommandToVerifyImageWithImageMagick } from './command.js';
import { handleIdentifyCommand } from '../../convert/video/local/node.js';
const IMAGEMAGICK_FORMAT_VARIANT_NAME = {
    jpeg: ['jpg'],
    jpg: ['jpeg'],
};
export async function verifyImageWithImageMagick(input) {
    const [cmd] = await buildCommandToVerifyImageWithImageMagick(input);
    const data = (await handleIdentifyCommand(cmd));
    if (IMAGE_MAGICK_FORMAT.includes(data.format) &&
        isFormatMatch(data.format, input.input.format)) {
        return true;
    }
    return false;
}
function isFormatMatch(a, b) {
    if (a === b) {
        return true;
    }
    const v = IMAGEMAGICK_FORMAT_VARIANT_NAME[a];
    if (v) {
        for (const x of v) {
            if (x === b) {
                return true;
            }
        }
    }
    return false;
}
//# sourceMappingURL=node.js.map