def check_sizes(size, width, height):
    """Check that these arguments, in supplied, are consistent.
    Return a (width, height) pair.
    """

    if not size:
        return width, height

    if len(size) != 2:
        raise ValueError(
            "size argument should be a pair (width, height)")
    if width is not None and width != size[0]:
        raise ValueError(
            "size[0] (%r) and width (%r) should match when both are used."
            % (size[0], width))
    if height is not None and height != size[1]:
        raise ValueError(
            "size[1] (%r) and height (%r) should match when both are used."
            % (size[1], height))
    return size
Check that these arguments, in supplied, are consistent.
    Return a (width, height) pair.
    
png.py