heicをjpegに変換する時
convert image.heic image.jpeg
で良い。 こうするとexifもカラープロファイルも維持されたまま変換される。
qualityは手元では92になった(この数字はどこから?)。望むなら100にすれば良いか。
exifを消したい時は http://blog.awm.jp/2017/06/11/imicc/#お勧めコマンド のままやってやると良さそう。
以下ここまでのあらすじと確認したところ。
— なな(久我山 菜々)🐇🏰🕛🥕 (@nonamea774) March 8, 2020
という疑問が出た。
あとは Exif を引き継ぐかどうかもチェック要素かも。 https://t.co/IQYgzgtyAU
— \助けよや/ (@yoya) March 8, 2020
ExifTools の Exif(+α)ダンプ機能は HEIF/HEIC にも対応してて、最新の ImageMagick の convert で変換した JPEG と比較してみた感じ、きちんと引き継げてる気がする。 pic.twitter.com/TNYehutEwl
— \助けよや/ (@yoya) March 8, 2020
まず手元のImageMagickが6.9系だったのでHEICをサポートしてるところまで上げる。
https://qiita.com/kinoleaf/items/df93150874bf0a6c9b9d#imagemagickのサポート状況 7.0.8-46とかその周辺らしい?
現在の最新の7.0.10-0をダウンロードしてきて
--with-heic
をつけてビルド(libheif-devを入れておくと良さそうな気がした)。convert
convert orig.heic out.jpeg
diff
diff -u heic jpeg
--- heic 2020-03-08 23:48:58.151954000 +0900
+++ jpeg 2020-03-08 23:49:23.841282300 +0900
@@ -1,19 +1,15 @@
ExifTool Version Number : 11.65
-File Name : orig.heic
+File Name : out.jpeg
Directory : .
-File Size : 2.1 MB
-File Modification Date/Time : 2020:03:08 23:22:09+09:00
-File Access Date/Time : 2020:03:08 23:22:09+09:00
-File Inode Change Date/Time : 2020:03:08 23:45:47+09:00
+File Size : 3.2 MB
+File Modification Date/Time : 2020:03:08 23:49:14+09:00
+File Access Date/Time : 2020:03:08 23:22:40+09:00
+File Inode Change Date/Time : 2020:03:08 23:49:14+09:00
File Permissions : rw-rw-rw-
-File Type : HEIC
-File Type Extension : heic
-MIME Type : image/heic
-Major Brand : High Efficiency Image Format HEVC still image (.HEIC)
-Minor Version : 0.0.0
-Compatible Brands : mif1, miaf, MiHB, heic
-Handler Type : Picture
-Primary Item Reference : 49
+File Type : JPEG
+File Type Extension : jpg
+MIME Type : image/jpeg
+JFIF Version : 1.01
Exif Byte Order : Big-endian (Motorola, MM)
Make : Apple
Camera Model Name : iPhone 11
@@ -103,29 +99,12 @@
Chromatic Adaptation : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
Blue Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
-HEVC Configuration Version : 1
-General Profile Space : Conforming
-General Tier Flag : Main Tier
-General Profile IDC : Main Still Picture Profile
-Gen Profile Compatibility Flags : Main Still Picture, Main 10, Main
-Constraint Indicator Flags : 176 0 0 0 0 0
-General Level IDC : 90 (level 3.0)
-Min Spatial Segmentation IDC : 0
-Parallelism Type : 0
-Chroma Format : 4:2:0
-Bit Depth Luma : 8
-Bit Depth Chroma : 8
-Average Frame Rate : 0
-Constant Frame Rate : Unknown
-Num Temporal Layers : 1
-Temporal ID Nested : No
Image Width : 4032
Image Height : 3024
-Image Spatial Extent : 4032x3024
-Rotation : 0
-Image Pixel Depth : 8 8 8
-Movie Data Size : 2169087
-Movie Data Offset : 3428
+Encoding Process : Baseline DCT, Huffman coding
+Bits Per Sample : 8
+Color Components : 3
+Y Cb Cr Sub Sampling : YCbCr4:4:4 (1 1)
Run Time Since Power Up : 3 days 21:19:35
Aperture : 2.4
Image Size : 4032x3024
convertで変換しても、exifはだいたい保持されてそう。
icc
$ convert out.jpeg out.icc
$ file out.icc
out.icc: ColorSync color profile 4.0, type appl, RGB/XYZ-mntr device by appl, 548 bytes, 7-7-2017 13:22:32, 0xca1a9582257f104d MD5 "Display P3"
iccプロファイルも保持されているのでOK。
orig.heif
$ exiftool orig.heic | tee heic
ExifTool Version Number : 11.65
File Name : orig.heic
Directory : .
File Size : 2.1 MB
File Modification Date/Time : 2020:03:08 23:22:09+09:00
File Access Date/Time : 2020:03:08 23:22:09+09:00
File Inode Change Date/Time : 2020:03:08 23:45:47+09:00
File Permissions : rw-rw-rw-
File Type : HEIC
File Type Extension : heic
MIME Type : image/heic
Major Brand : High Efficiency Image Format HEVC still image (.HEIC)
Minor Version : 0.0.0
Compatible Brands : mif1, miaf, MiHB, heic
Handler Type : Picture
Primary Item Reference : 49
Exif Byte Order : Big-endian (Motorola, MM)
Make : Apple
Camera Model Name : iPhone 11
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Software : 13.3.1
Modify Date : 2020:03:07 16:18:29
Y Cb Cr Positioning : Centered
Exposure Time : 1/500
F Number : 2.4
Exposure Program : Program AE
ISO : 20
Exif Version : 0231
Date/Time Original : 2020:03:07 16:18:29
Create Date : 2020:03:07 16:18:29
Offset Time : +09:00
Offset Time Original : +09:00
Offset Time Digitized : +09:00
Components Configuration : Y, Cb, Cr, -
Shutter Speed Value : 1/500
Aperture Value : 2.4
Brightness Value : 8.968155267
Exposure Compensation : 0
Metering Mode : Multi-segment
Flash : Off, Did not fire
Focal Length : 1.5 mm
Subject Area : 2015 1510 2323 1392
Run Time Flags : Valid
Run Time Value : 335975424399875
Run Time Scale : 1000000000
Run Time Epoch : 0
Acceleration Vector : -0.9370931979 -0.01936975682 0.3228254023
Content Identifier : 16488392-0B18-41F3-8C47-80F640D3EDA6
Sub Sec Time Original : 543
Sub Sec Time Digitized : 543
Flashpix Version : 0100
Color Space : Uncalibrated
Exif Image Width : 4032
Exif Image Height : 3024
Sensing Method : One-chip color area
Scene Type : Directly photographed
Exposure Mode : Auto
White Balance : Auto
Digital Zoom Ratio : 1.022312373
Focal Length In 35mm Format : 14 mm
Scene Capture Type : Standard
Lens Info : 1.54-4.25mm f/1.8-2.4
Lens Make : Apple
Lens Model : iPhone 11 back dual wide camera 1.54mm f/2.4
Composite Image : General Composite Image
GPS Latitude Ref : North
GPS Longitude Ref : East
GPS Altitude Ref : Above Sea Level
GPS Speed Ref : km/h
GPS Speed : 0.687995255
GPS Img Direction Ref : True North
GPS Img Direction : 97.10734846
GPS Dest Bearing Ref : True North
GPS Dest Bearing : 97.10734846
GPS Date Stamp : 2020:03:07
GPS Horizontal Positioning Error: 22.8772038 m
Profile CMM Type : Apple Computer Inc.
Profile Version : 4.0.0
Profile Class : Display Device Profile
Color Space Data : RGB
Profile Connection Space : XYZ
Profile Date Time : 2017:07:07 13:22:32
Profile File Signature : acsp
Primary Platform : Apple Computer Inc.
CMM Flags : Not Embedded, Independent
Device Manufacturer : Apple Computer Inc.
Device Model :
Device Attributes : Reflective, Glossy, Positive, Color
Rendering Intent : Perceptual
Connection Space Illuminant : 0.9642 1 0.82491
Profile Creator : Apple Computer Inc.
Profile ID : ca1a9582257f104d389913d5d1ea1582
Profile Description : Display P3
Profile Copyright : Copyright Apple Inc., 2017
Media White Point : 0.95045 1 1.08905
Red Matrix Column : 0.51512 0.2412 -0.00105
Green Matrix Column : 0.29198 0.69225 0.04189
Blue Matrix Column : 0.1571 0.06657 0.78407
Red Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Chromatic Adaptation : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
Blue Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
HEVC Configuration Version : 1
General Profile Space : Conforming
General Tier Flag : Main Tier
General Profile IDC : Main Still Picture Profile
Gen Profile Compatibility Flags : Main Still Picture, Main 10, Main
Constraint Indicator Flags : 176 0 0 0 0 0
General Level IDC : 90 (level 3.0)
Min Spatial Segmentation IDC : 0
Parallelism Type : 0
Chroma Format : 4:2:0
Bit Depth Luma : 8
Bit Depth Chroma : 8
Average Frame Rate : 0
Constant Frame Rate : Unknown
Num Temporal Layers : 1
Temporal ID Nested : No
Image Width : 4032
Image Height : 3024
Image Spatial Extent : 4032x3024
Rotation : 0
Image Pixel Depth : 8 8 8
Movie Data Size : 2169087
Movie Data Offset : 3428
Run Time Since Power Up : 3 days 21:19:35
Aperture : 2.4
Image Size : 4032x3024
Megapixels : 12.2
Scale Factor To 35 mm Equivalent: 9.1
Shutter Speed : 1/500
Create Date : 2020:03:07 16:18:29.543+09:00
Date/Time Original : 2020:03:07 16:18:29.543+09:00
Modify Date : 2020:03:07 16:18:29+09:00
GPS Altitude : 14 m Above Sea Level
GPS Latitude : 35 deg 10' 16.28" N
GPS Longitude : 136 deg 53' 0.60" E
Circle Of Confusion : 0.003 mm
Field Of View : 104.3 deg
Focal Length : 1.5 mm (35 mm equivalent: 14.0 mm)
GPS Position : 35 deg 10' 16.28" N, 136 deg 53' 0.60" E
Hyperfocal Distance : 0.30 m
Light Value : 13.8