How to work with HEIC image file types in Python

后端 未结 6 1005
醉梦人生
醉梦人生 2021-01-31 18:08

The High Efficiency Image File (HEIF) format is the default when airdropping an image from an iPhone to a OSX device. I want to edit and modify these .HEIC files with Python.

6条回答
  •  既然无缘
    2021-01-31 18:19

    I was quite successful with Wand package : Install Wand: https://docs.wand-py.org/en/0.6.4/ Code for conversion:

       from wand.image import Image
       import os
    
       SourceFolder="K:/HeicFolder"
       TargetFolder="K:/JpgFolder"
    
       for file in os.listdir(SourceFolder):
          SourceFile=SourceFolder + "/" + file
          TargetFile=TargetFolder + "/" + file.replace(".HEIC",".JPG")
        
          img=Image(filename=SourceFile)
          img.format='jpg'
          img.save(filename=TargetFile)
          img.close()
    

提交回复
热议问题