// Detect It Easy: detection rule file
// Author: LinXP
// doc-ref: https://qoiformat.org/qoi-specification.pdf

meta("image", "Quite OK Image (.QOI)");

function detect() {
    if (Binary.getSize() >= 0x0E) {
        if (Binary.compare("'qoif'")) {
            bDetected = true;

            sOptions = sOptions.append(Binary.read_uint32(0x04, _BE) + "x" + Binary.read_uint32(0x08, _BE));
            switch (File.read_uint8(0x0C)) {
                case 3: sOption("RGB"); break;
                case 4: sOption("RGBA"); break;
                default: return;
            }
            switch (File.read_uint8(0x0D)) {
                case 0: sOption("sRGB with linear alpha"); break;
                case 1: sOption("all channels linear"); break;
                default: return;
            }
        }
    }

    return result();
}