def _write_frame(self, id_, image, jpeg_encode_quality=_DEFAULT_JPEG_QUALITY):
    loc = self.fp.tell()
    if isinstance(image, (str, Path)):
        with open(str(image), 'rb') as image_file:
            img_str = image_file.read()
        if (not is_jpeg(img_str)):
            raise FileFormatException(f'Image file from path {image} does not appear to be a JPEG file.')
    else:
        img_str = img_to_jpeg_bytes(image, jpeg_encode_quality)
    assert (len(img_str) > 0)
    pad = self._pad_image(len(img_str))
    record = img_str.ljust((len(img_str) + pad), b'\x00')
    assert (len(record) > 0)
    img_info = ImgInfo(loc=loc, length=len(record), pad=pad)
    id_ = str(id_)
    if (id_ not in self.meta_dict):
        self.meta_dict[id_] = self._default_factory()
    self.meta_dict[id_]['frame_info'].append(img_info)
    self.fp.write(record)
def _write_frame(self, id_, image, jpeg_encode_quality=_DEFAULT_JPEG_QUALITY):
    loc = self.fp.tell()
    if isinstance(image, (str, Path)):
        with open(str(image), 'rb') as image_file:
            img_str = image_file.read()
        if (not is_jpeg(img_str)):
            raise FileFormatException(f'Image file from path {image} does not appear to be a JPEG file.')
    else:
        img_str = img_to_jpeg_bytes(image, jpeg_encode_quality)
    assert (len(img_str) > 0)
    pad = self._pad_image(len(img_str))
    record = img_str.ljust((len(img_str) + pad), b'\x00')
    assert (len(record) > 0)
    img_info = ImgInfo(loc=loc, length=len(record), pad=pad)
    id_ = str(id_)
    if (id_ not in self.meta_dict):
        self.meta_dict[id_] = self._default_factory()
    self.meta_dict[id_]['frame_info'].append(img_info)
    self.fp.write(record)