はじめに

Imagemagickを使用して、heicファイルを pngに変換したかったので備忘録としてメモしておく。

環境

1
2
3
4
5
6
MacOS sonoma 14.2.1
Homebrew 4.2.4

ImageMagick 7.1.1-26 Q16-HDRI x86_64 21914 https://imagemagick.org
Delegates (built-in): bzlib fontconfig freetype gslib heic jng jp2 jpeg jxl lcms lqr ltdl lzma openexr png ps raw tiff webp xml zlib zstd
Compiler: gcc (4.2)

Imagemagickのインストール

1
brew install imagemagick
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
==> Downloading https://ghcr.io/v2/homebrew/core/imagemagick/manifests/7.1.1-26
############################################################################################################## 100.0%
==> Fetching dependencies for imagemagick: jbig2dec, libidn, openjpeg, ghostscript, libde265, shared-mime-info, x265,
 libheif, liblqr, jasper, libomp and libraw                                                                          ==> Downloading https://ghcr.io/v2/homebrew/core/jbig2dec/manifests/0.20
############################################################################################################## 100.0%
==> Fetching jbig2dec
==> Downloading https://ghcr.io/v2/homebrew/core/jbig2dec/blobs/sha256:8017bcda4a2d530aad05946e2196907a8fd52992aa3043
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libidn/manifests/1.42
############################################################################################################## 100.0%
==> Fetching libidn
==> Downloading https://ghcr.io/v2/homebrew/core/libidn/blobs/sha256:93f6802767b31f0f6b8baeafc8cbc07df4312879cf241671
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openjpeg/manifests/2.5.0_1
############################################################################################################## 100.0%
==> Fetching openjpeg
==> Downloading https://ghcr.io/v2/homebrew/core/openjpeg/blobs/sha256:7ac174c6d8b1d7b0350a184a53a5086208cb54bbdbe215
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ghostscript/manifests/10.02.1
############################################################################################################## 100.0%
==> Fetching ghostscript
==> Downloading https://ghcr.io/v2/homebrew/core/ghostscript/blobs/sha256:16c06c980a9042d4cc6bfb25066bbd5115e79844491
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libde265/manifests/1.0.15
############################################################################################################## 100.0%
==> Fetching libde265
==> Downloading https://ghcr.io/v2/homebrew/core/libde265/blobs/sha256:baa8684dbb6aa00aac5a0b9b4d3e670df8cbd4d0c6635e
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/shared-mime-info/manifests/2.4
############################################################################################################## 100.0%
==> Fetching shared-mime-info
==> Downloading https://ghcr.io/v2/homebrew/core/shared-mime-info/blobs/sha256:cbaf7565626aac827d36135bb5c7a034d36f76
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/x265/manifests/3.5-1
############################################################################################################## 100.0%
==> Fetching x265
==> Downloading https://ghcr.io/v2/homebrew/core/x265/blobs/sha256:26943ec04286b0669309ea55b9eff3db0bb581761be7b21170
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libheif/manifests/1.17.6
############################################################################################################## 100.0%
==> Fetching libheif
==> Downloading https://ghcr.io/v2/homebrew/core/libheif/blobs/sha256:dc7e4ab57ef422d3d5aa23373ba024e68ab1b9e65f452d9
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/liblqr/manifests/0.4.2_1-2
############################################################################################################## 100.0%
==> Fetching liblqr
==> Downloading https://ghcr.io/v2/homebrew/core/liblqr/blobs/sha256:03a0e5288bac04044c068ebc27e26cc834f1f2ae483aa7e2
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/jasper/manifests/4.1.2
############################################################################################################## 100.0%
==> Fetching jasper
==> Downloading https://ghcr.io/v2/homebrew/core/jasper/blobs/sha256:aa96ecd9424de0b78ceb6423e3910563b44206ba15f2bbe4
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libomp/manifests/17.0.6
############################################################################################################## 100.0%
==> Fetching libomp
==> Downloading https://ghcr.io/v2/homebrew/core/libomp/blobs/sha256:1c8c2254625ca8e941eb2a0cec32e2488bbe16fdd5bd11a0
############################################################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libraw/manifests/0.21.2
############################################################################################################## 100.0%
==> Fetching libraw
==> Downloading https://ghcr.io/v2/homebrew/core/libraw/blobs/sha256:b560a97e92ec19e74813e167d2390e60a2fe583206119fed
############################################################################################################## 100.0%
==> Fetching imagemagick
==> Downloading https://ghcr.io/v2/homebrew/core/imagemagick/blobs/sha256:dcf0236086769680fdfe8d42847698bcc2d745596ab
############################################################################################################## 100.0%
==> Installing dependencies for imagemagick: jbig2dec, libidn, openjpeg, ghostscript, libde265, shared-mime-info, x26
5, libheif, liblqr, jasper, libomp and libraw                                                                        ==> Installing imagemagick dependency: jbig2dec
==> Downloading https://ghcr.io/v2/homebrew/core/jbig2dec/manifests/0.20
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/8d21a0eddc94902acc1bb126cf78e775c7b2381f255
32e02a7f9e2974a817577--jbig2dec-0.20.bottle_manifest.json                                                            ==> Pouring jbig2dec--0.20.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/jbig2dec/0.20: 13 files, 375.4KB
==> Installing imagemagick dependency: libidn
==> Downloading https://ghcr.io/v2/homebrew/core/libidn/manifests/1.42
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/786bf942d09cb90f8745be7db019bfd8ba760f0bf10
9f78bb1b787d5ab7490db--libidn-1.42.bottle_manifest.json                                                              ==> Pouring libidn--1.42.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/libidn/1.42: 73 files, 1MB
==> Installing imagemagick dependency: openjpeg
==> Downloading https://ghcr.io/v2/homebrew/core/openjpeg/manifests/2.5.0_1
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/d3acfd3e45dc08593423b30691238e57dfba97ca414
63eae5b4d04ffc9a6e1c5--openjpeg-2.5.0_1.bottle_manifest.json                                                         ==> Pouring openjpeg--2.5.0_1.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/openjpeg/2.5.0_1: 541 files, 13.9MB
==> Installing imagemagick dependency: ghostscript
==> Downloading https://ghcr.io/v2/homebrew/core/ghostscript/manifests/10.02.1
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/ba9df8e1faa9473b0bc519feae603accbf1d5a10293
26f3e721b9160e23c41be--ghostscript-10.02.1.bottle_manifest.json                                                      ==> Pouring ghostscript--10.02.1.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/ghostscript/10.02.1: 639 files, 151.7MB
==> Installing imagemagick dependency: libde265
==> Downloading https://ghcr.io/v2/homebrew/core/libde265/manifests/1.0.15
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/aa9fa450f5b69a17cf97f33ff41d5c33f72f878af2a
3d643de4f3d99b741e0d4--libde265-1.0.15.bottle_manifest.json                                                          ==> Pouring libde265--1.0.15.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/libde265/1.0.15: 21 files, 1.5MB
==> Installing imagemagick dependency: shared-mime-info
==> Downloading https://ghcr.io/v2/homebrew/core/shared-mime-info/manifests/2.4
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/b939513ada122d80abd08624d26056d1bf65b49a2b2
ed794db163a91db90dbab--shared-mime-info-2.4.bottle_manifest.json                                                     ==> Pouring shared-mime-info--2.4.sonoma.bottle.tar.gz
==> /usr/local/Cellar/shared-mime-info/2.4/bin/update-mime-database /usr/local/share/mime
🍺  /usr/local/Cellar/shared-mime-info/2.4: 88 files, 4.7MB
==> Installing imagemagick dependency: x265
==> Downloading https://ghcr.io/v2/homebrew/core/x265/manifests/3.5-1
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/b2b1f388528d2c8033213ea1b60ecf69affc11dc2e9
d2a90d94831e2851bfb16--x265-3.5-1.bottle_manifest.json                                                               ==> Pouring x265--3.5.sonoma.bottle.1.tar.gz
🍺  /usr/local/Cellar/x265/3.5: 11 files, 35.8MB
==> Installing imagemagick dependency: libheif
==> Downloading https://ghcr.io/v2/homebrew/core/libheif/manifests/1.17.6
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/06ea264285fbf2e0d5d3999fd52ed147f727f5d65a8
3f5306fea04da6166b9e7--libheif-1.17.6.bottle_manifest.json                                                           ==> Pouring libheif--1.17.6.sonoma.bottle.tar.gz
==> /usr/local/opt/shared-mime-info/bin/update-mime-database /usr/local/share/mime
🍺  /usr/local/Cellar/libheif/1.17.6: 29 files, 3.7MB
==> Installing imagemagick dependency: liblqr
==> Downloading https://ghcr.io/v2/homebrew/core/liblqr/manifests/0.4.2_1-2
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/47fefd703ba858f276c3793ea02c6432b74ceb7a3f1
fa1fdf882e2f925f601cc--liblqr-0.4.2_1-2.bottle_manifest.json                                                         ==> Pouring liblqr--0.4.2_1.sonoma.bottle.2.tar.gz
🍺  /usr/local/Cellar/liblqr/0.4.2_1: 113 files, 300.3KB
==> Installing imagemagick dependency: jasper
==> Downloading https://ghcr.io/v2/homebrew/core/jasper/manifests/4.1.2
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/520da00e71e699cd4824fa9fccf56cfff2bcbdf176b
7b37235650057f74ab49d--jasper-4.1.2.bottle_manifest.json                                                             ==> Pouring jasper--4.1.2.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/jasper/4.1.2: 44 files, 1.5MB
==> Installing imagemagick dependency: libomp
==> Downloading https://ghcr.io/v2/homebrew/core/libomp/manifests/17.0.6
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/bf5fde8dea0410e4b63ba26d1b6d752bae6746ad97a
1e3f37a065e2c5a7abdb3--libomp-17.0.6.bottle_manifest.json                                                            ==> Pouring libomp--17.0.6.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/libomp/17.0.6: 7 files, 1.7MB
==> Installing imagemagick dependency: libraw
==> Downloading https://ghcr.io/v2/homebrew/core/libraw/manifests/0.21.2
Already downloaded: /Users/horibahiroto/Library/Caches/Homebrew/downloads/9486d462a427bd1b90a94393ea1e8304f3b9974455e
794f2c03a1c2622edc48c--libraw-0.21.2.bottle_manifest.json                                                            ==> Pouring libraw--0.21.2.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/libraw/0.21.2: 73 files, 5.7MB
==> Installing imagemagick
==> Pouring imagemagick--7.1.1-26.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/imagemagick/7.1.1-26: 809 files, 29MB
==> Running `brew cleanup imagemagick`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

heicからpngへの変換  

コマンド

1
magick convert [HEICファイル名].HEIC [出力ファイル名].png

でいける。

下記で実行をした。

1
magick convert static/image/column/pass-db/db-result-2023-2.HEIC static/image/column/pass-db/db-result-2023-2.png

pngファイルが指定したパスに生成されていればOK!

参考

おわりに

Web上で変換できるサイトも多いが、写真保存されたりしたら嫌なのでコマンドでローカル実行がしたかった。
調べてみたところ、imagemagickを使えばできるとのことなので試してみたが、結構簡単にできた!