"""Write the primary HEIF still as a model-sized JPEG. libheif applies rotation.""" import sys from PIL import Image from pillow_heif import HeifImageFile # The bridge also recognizes compatible brands that Pillow's registry misses. with HeifImageFile(sys.argv[1]) as photo: if ( Image.MAX_IMAGE_PIXELS is not None and photo.width * photo.height > Image.MAX_IMAGE_PIXELS ): raise ValueError("HEIF image exceeds the pixel limit") photo.thumbnail((2000, 2000)) rgb = photo.convert("RGB") rgb.info.clear() rgb.save(sys.argv[2], format="JPEG", quality=85)