'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 1:[1]
As of today, I haven't found a way to do this with a Python-only solution. If you need a workaround, you can find any Windows command line utility that will do the conversion for you, and call that as a subprocess from Python.
Here is an example option using PowerShell: https://github.com/DavidAnson/ConvertTo-Jpeg
It's also pretty easy these days to write a .NET-based console app that uses Magick.NET. That's what I ended up doing.
Solution 2:[2]
Just was looking at the same topic. I came across this:
https://pypi.org/project/heic-to-jpg/
I haven't had time to look more into this, but thought I'd share this.
Solution 3:[3]
In the latest version of pillow_heic module, below code will work fine. only read_heif is replaced with read.
from PIL import Image
import pillow_heif
heif_file = pillow_heif.read(r"E:\image\20210914_150826.heic")
image = Image.frombytes(
heif_file.mode,
heif_file.size,
heif_file.data,
"raw",
)
image.save(r"E:\image\test.png", format("png"))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Volsie711 |
| Solution 3 | deepesh |
