// DIE's signature file

init("image","PNG");

function detect(bShowType,bShowVersion,bShowOptions)
{
    if(Binary.getSize()>=48)
    {
        if(Binary.compare("89'PNG\r\n'1A0A........'IHDR'"))
        {
            if(Binary.readByte(28))
            {
                sOptions="interlaced";
            }
            sOptions=sOptions.append(Binary.readBEDword(16)+"x"+Binary.readBEDword(20));
            var sColor="";
            switch(Binary.readByte(25))
            {
            case 0: sColor="grey";       break;
            case 2: sColor="RGB";        break;
            case 3: sColor="index";      break;
            case 4: sColor="grey+alpha"; break;
            case 6: sColor="RGBA";       break;
            }
            if(sColor!="")
            {
                sOptions=sOptions.append(Binary.readByte(24)+"-bit "+sColor);
            }
            bDetected=1;
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
