def check_bitdepth_colortype(bitdepth, colortype):
 if (bitdepth not in (1, 2, 4, 8, 16)):
  raise FormatError(('invalid bit depth %d' % bitdepth))
 if (colortype not in (0, 2, 3, 4, 6)):
  raise FormatError(('invalid colour type %d' % colortype))
 if ((colortype & 1) and (bitdepth > 8)):
  raise FormatError(('Indexed images (colour type %d) cannot have bitdepth > 8 (bit depth %d). See http://www.w3.org/TR/2003/REC-PNG-20031110/#table111 .' % (bitdepth, colortype)))
 if ((bitdepth < 8) and (colortype not in (0, 3))):
  raise FormatError(('Illegal combination of bit depth (%d) and colour type (%d). See http://www.w3.org/TR/2003/REC-PNG-20031110/#table111 .' % (bitdepth, colortype)))

def check_bitdepth_colortype ( bitdepth , colortype ) : if ( bitdepth not in ( 1 , 2 , 4 , 8 , 16 ) ) : raise FormatError ( ( 'invalid bit depth %d' % bitdepth ) ) if ( colortype not in ( 0 , 2 , 3 , 4 , 6 ) ) : raise FormatError ( ( 'invalid colour type %d' % colortype ) ) if ( ( colortype & 1 ) and ( bitdepth > 8 ) ) : raise FormatError ( ( 'Indexed images (colour type %d) cannot have bitdepth > 8 (bit depth %d). See http://www.w3.org/TR/2003/REC-PNG-20031110/#table111 .' % ( bitdepth , colortype ) ) ) if ( ( bitdepth < 8 ) and ( colortype not in ( 0 , 3 ) ) ) : raise FormatError ( ( 'Illegal combination of bit depth (%d) and colour type (%d). See http://www.w3.org/TR/2003/REC-PNG-20031110/#table111 .' % ( bitdepth , colortype ) ) )
check that bitdepth and colortype are both valid .