// Detect It Easy: detection rule file
// Author: LinXP

meta("image", "Encapsulated PostScript (.EPS)");

function detect() {
    if (Binary.getSize() >= 0x40) {
        if (Binary.compare("'%!PS-Adobe-'", 0x00) && Binary.compare("' EPSF-'", 0x0E)) {
            sVersion = sVersion.append(Binary.getString(0x0B, 0x03), Binary.getString(0x14, 0x03));
            var sText = Binary.getString(0x00, 0x0400)
            bDetected = true;
            if (Binary.isVerbose()) {
                var aCreator = sText.match(/%%Creator: (.*?)[\r\n]/);
                if (aCreator) {
                    sOptions = sOptions.append("Creator:" + aCreator[1]);
                }
                var aPages = sText.match(/%%Pages: (.*?)[\r\n]/);
                if (aPages) {
                    sOptions = sOptions.append("Pages:" + aPages[1]);
                }
            }
        }
    }

    return result();
}