Parses size string into a tuple

        :param size: String on the form '100', 'x100 or '100x200'
        :return: Tuple of two integers for width and height
        :rtype: tuple

def parse_size(size):
        """
        Parses size string into a tuple

        :param size: String on the form '100', 'x100 or '100x200'
        :return: Tuple of two integers for width and height
        :rtype: tuple
        """
        if size.startswith('x'):
            return None, int(size.replace('x', ''))
        if 'x' in size:
            return int(size.split('x')[0]), int(size.split('x')[1])
        return int(size), None