1234567891011121314151617181920 |
- def conv(heic_path, save_dir, filetype, quality):
- # 悵湔珂及犯奴伊弁玄伉午白央奶伙靡
- extension = "." + filetype
- save_path = save_dir / filetype / pathlib.Path(*heic_path.parts[1:]).with_suffix(extension)
- # 白巧伙母釬傖
- save_path.parent.mkdir(parents=True, exist_ok=True)
- # HEIC白央奶伙pyheif匹掂心煋心
- heif_file = pyheif.read(heic_path)
- # 掂心煋氏分白央奶伙及笢旯毛data劐杅尺
- data = Image.frombytes(
- heif_file.mode,
- heif_file.size,
- heif_file.data,
- "raw",
- heif_file.mode,
- heif_file.stride,
- )
- # JPEG匹悵湔
- data.save(save_path, quality=quality)
- print("悵湔ㄩ", save_path)
|