Problem to convert .heic image format file as an input¶
Failure
I tried some versions on imagemagick, but the default installed version seems not support .HEIC format. I need to convert HEIC to jpeg format for my pictures taken by iphone.
Default installed magick on ubuntu(command is located in /usr/bin/convert) : Not support HEIC
Edit /etc/apt/sources.list and add deb(archive contains binary packages) and deb-src(source packages) at the bottom of the file.
/etc/apt/sources.list
1234
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
Download and install ImageMagick7.cd into /opt, do configuration as with-heic=yes and install. The version of ImageMagick-7.0.11-0 is the latest one as of 16 Feb 2021.
12345678
$ cd /opt
$ sudo wget https://www.imagemagick.org/download/ImageMagick-7.0.11-0.tar.gz
$ sudo tar xvzf ImageMagick-7.0.11-0.tar.gz
$ cd ImageMagick-7.0.11-0
$ sudo ./configure --with-heic=yes
$ sudo make
$ sudo make install # $ `sudo checkinstall` may work here if you have that.
$ sudo ldconfig /usr/local/lib # this creates the necessary links and cache to the most recent shared libraries in /usr/local/lib
Then you reopen terminal, you should have:
1 2 3 4 5 6 7 8 91011121314
$ which magick
/usr/local/bin/magick
$ which convert
/usr/local/bin/convert
$ convert --version
Version: ImageMagick 7.0.11-0 Q16 x86_64 2021-02-13 https://imagemagick.org
Copyright: (C)1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): bzlib djvu fftw fontconfig freetype heic jbig jng jpeg lcms lqr lzma openexr pangocairo png tiff x xml zlib
# magic --version has the same output above
Success
Finally, imagemagick on ubuntu supported .heic files.
1234
$ convert ubuntu-install1.heic ubuntu-install1.jpg
$ ls
ubuntu-install1.heic ubuntu-install1.jpg
If you want batch conversion,
1 2 3 4 5 6 7 8 9101112131415161718192021
$ mogrify -format jpg -resize 800x -quality 90% -strip *.heic
$ ls -alrt
total 22028
-rw-rw-r-- 1 tato tato 1783285 2月 1601:42 ubuntu-install8.heic
-rw-rw-r-- 1 tato tato 3104249 2月 1601:42 ubuntu-install7.heic
-rw-rw-r-- 1 tato tato 2763850 2月 1601:42 ubuntu-install6.heic
-rw-rw-r-- 1 tato tato 3060560 2月 1601:42 ubuntu-install5.heic
-rw-rw-r-- 1 tato tato 2216210 2月 1601:43 ubuntu-install4.heic
-rw-rw-r-- 1 tato tato 2463248 2月 1601:43 ubuntu-install3.heic
-rw-rw-r-- 1 tato tato 3169240 2月 1601:43 ubuntu-install2.heic
-rw-rw-r-- 1 tato tato 3115121 2月 1601:43 ubuntu-install1.heic
drwxr-xr-x 27 tato tato 4096 2月 1712:14 ..
-rw-r--r-- 1 tato tato 103615 2月 1723:22 ubuntu-install1.jpg
-rw-r--r-- 1 tato tato 124111 2月 1723:22 ubuntu-install2.jpg
-rw-r--r-- 1 tato tato 97677 2月 1723:22 ubuntu-install3.jpg
-rw-r--r-- 1 tato tato 98592 2月 1723:22 ubuntu-install4.jpg
-rw-r--r-- 1 tato tato 112623 2月 1723:22 ubuntu-install5.jpg
-rw-r--r-- 1 tato tato 117368 2月 1723:22 ubuntu-install6.jpg
-rw-r--r-- 1 tato tato 116172 2月 1723:22 ubuntu-install7.jpg
-rw-r--r-- 1 tato tato 67882 2月 1723:22 ubuntu-install8.jpg
Script (Build source with configuring to apply heic format)¶