pythonpython-imaging-libraryjpegheic

How to Convert From HEIC to JPG in Python on WIndows


Im trying to convert HEIC to JPG using python. The only other answers about this topic used pyheif. I am on windows and pyheif doesn't support windows. Any suggestions? I am currently trying to use pillow.


Solution

  • The following code will convert an HEIC file format to a PNG file format

    from PIL import Image
    import pillow_heif
    
    heif_file = pillow_heif.read_heif("HEIC_file.HEIC")
    image = Image.frombytes(
        heif_file.mode,
        heif_file.size,
        heif_file.data,
        "raw",
    )
    
    image.save("./picture_name.png", format("png"))