title: How to work with HEIC image file types in Python
body: <p>The <a href="https://www.wikiwand.com/en/High_Efficiency_Image_File_Format" rel="noreferrer">High Efficiency Image File</a> (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.</p>
  
  <p>I could modify phone settings to save as JPG by default but that doesn't really solve the problem of being able to work with the filetype from others.  I still want to be able to process HEIC files for doing file conversion, extracting metadata, etc. (<a href="https://developer.here.com/blog/getting-started-with-geocoding-exif-image-metadata-in-python3" rel="noreferrer">Example Use Case -- Geocoding</a>)</p>
  
  <p><strong>Pillow</strong></p>
  
  <p>Here is the result of working with Python 3.7 and Pillow when trying to read a file of this type.</p>
  
  <pre><code>$ ipython
  Python 3.7.0 (default, Oct  2 2018, 09:20:07)
  Type 'copyright', 'credits' or 'license' for more information
  IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.
  
  In [1]: from PIL import Image
  
  In [2]: img = Image.open('IMG_2292.HEIC')
  ---------------------------------------------------------------------------
  OSError                                   Traceback (most recent call last)
  &lt;ipython-input-2-fe47106ce80b&gt; in &lt;module&gt;
  ----&gt; 1 img = Image.open('IMG_2292.HEIC')
  
  ~/.env/py3/lib/python3.7/site-packages/PIL/Image.py in open(fp, mode)
     2685         warnings.warn(message)
     2686     raise IOError("cannot identify image file %r"
  -&gt; 2687                   % (filename if filename else fp))
     2688
     2689 #
  
  OSError: cannot identify image file 'IMG_2292.HEIC'
  </code></pre>
  
  <p>It looks like support in python-pillow was requested (<a href="https://github.com/python-pillow/Pillow/issues/2806" rel="noreferrer">#2806</a>) but there are licensing / patent issues preventing it there.  </p>
  
  <p><strong>ImageMagick + Wand</strong></p>
  
  <p>It appears that <a href="https://github.com/ImageMagick/ImageMagick/issues/507" rel="noreferrer">ImageMagick</a> may be an option.  After doing a <code>brew install imagemagick</code> and <code>pip install wand</code> however I was unsuccessful.</p>
  
  <pre><code>$ ipython
  Python 3.7.0 (default, Oct  2 2018, 09:20:07)
  Type 'copyright', 'credits' or 'license' for more information
  IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.
  
  In [1]: from wand.image import Image
  
  In [2]: with Image(filename='img.jpg') as img:
     ...:     print(img.size)
     ...:
  (4032, 3024)
  
  In [3]: with Image(filename='img.HEIC') as img:
     ...:     print(img.size)
     ...:
  ---------------------------------------------------------------------------
  MissingDelegateError                      Traceback (most recent call last)
  &lt;ipython-input-3-9d6f58c40f95&gt; in &lt;module&gt;
  ----&gt; 1 with Image(filename='ces2.HEIC') as img:
        2     print(img.size)
        3
  
  ~/.env/py3/lib/python3.7/site-packages/wand/image.py in __init__(self, image, blob, file, filename, format, width, height, depth, background, resolution, pseudo)
     4603                     self.read(blob=blob, resolution=resolution)
     4604                 elif filename is not None:
  -&gt; 4605                     self.read(filename=filename, resolution=resolution)
     4606                 # clear the wand format, otherwise any subsequent call to
     4607                 # MagickGetImageBlob will silently change the image to this
  
  ~/.env/py3/lib/python3.7/site-packages/wand/image.py in read(self, file, filename, blob, resolution)
     4894             r = library.MagickReadImage(self.wand, filename)
     4895         if not r:
  -&gt; 4896             self.raise_exception()
     4897
     4898     def save(self, file=None, filename=None):
  
  ~/.env/py3/lib/python3.7/site-packages/wand/resource.py in raise_exception(self, stacklevel)
      220             warnings.warn(e, stacklevel=stacklevel + 1)
      221         elif isinstance(e, Exception):
  --&gt; 222             raise e
      223
      224     def __enter__(self):
  
  MissingDelegateError: no decode delegate for this image format `HEIC' @ error/constitute.c/ReadImage/556
  </code></pre>
  
  <p>Any other alternatives available to do a conversion programmatically?</p>