<commit_before># -*- coding: utf-8 -*-

from datetime import datetime

TAG_WIDTH = 'EXIF ExifImageWidth'
TAG_HEIGHT = 'EXIF ExifImageLength'
TAG_DATETIME = 'Image DateTime'

def parse_time(tags):
    tag = tags.get(TAG_DATETIME, None)
    if not tag:<commit_msg>Add homemade fast width/height reader for JPEG files<commit_after># -*- coding: utf-8 -*-

import struct
from datetime import datetime

TAG_WIDTH = 'EXIF ExifImageWidth'
TAG_HEIGHT = 'EXIF ExifImageLength'
TAG_DATETIME = 'Image DateTime'


def jpeg_size(path):
    """Get image size.
    Structure of JPEG file is:
        ffd8 [ffXX SSSS DD DD ...] [ffYY SSSS DDDD ...]  (S is 16bit size, D the data)
    We look for the SOF0 header 0xffc0; its structure is
       [ffc0 SSSS PPHH HHWW ...] where PP is 8bit precision, HHHH 16bit height, WWWW width
    """
    with open(path, 'rb') as f:
        _, header_type, size = struct.unpack('>HHH', f.read(6))
        while header_type != 0xffc0:
            f.seek(size - 2, 1)
            header_type, size = struct.unpack('>HH', f.read(4))
        bpi, height, width = struct.unpack('>BHH', f.read(5))
    return width, height


def parse_time(tags):
    tag = tags.get(TAG_DATETIME, None)
    if not tag:
{'fraction_non_alphanumeric': 0.12026359143327842, 'fraction_numerical': 0.015650741350906095, 'mean_word_length': 3.077181208053691, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3344397', 'n_tokens_mistral': 446, 'n_tokens_neox': 429, 'n_words': 132}