MCPcopy Index your code
hub / github.com/unclecode/crawl4ai / parse_dimension

Function parse_dimension

crawl4ai/utils.py:546–553  ·  view source on GitHub ↗
(dimension)

Source from the content-addressed store, hash-verified

544 def score_image_for_usefulness(img, base_url, index, images_count):
545 # Function to parse image height/width value and units
546 def parse_dimension(dimension):
547 if dimension:
548 match = re.match(r"(\d+)(\D*)", dimension)
549 if match:
550 number = int(match.group(1))
551 unit = match.group(2) or 'px' # Default unit is 'px' if not specified
552 return number, unit
553 return None, None
554
555 # Fetch image file metadata to extract size and extension
556 def fetch_image_file_size(img, base_url):

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…