ImageMagick 的 HEIC 操作产生无效输出

HEIC operations with ImageMagick produce invalid output

这些操作有效:

这些操作产生无效输出:

无效输出意味着:元数据​​显示正确但 MacOS 预览抱怨:“The file “c.heic” could not be opened. It may be damaged or use a file format that Preview doesn’t recognise.”。

输入文件的元数据c.jpg

c.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=11, manufacturer=Apple, model=iPhone 11 Pro, orientation=upper-left, xresolution=166, yresolution=174, resolutionunit=2, software=14.0.1, datetime=2021:06:15 17:59:12, GPS-Data], baseline, precision 8, 3024x4032, components 3

ExifTool Version Number         : 12.26
File Name                       : c.jpg
Directory                       : /Users/pepa/Downloads/imageTests/a
File Size                       : 3.4 MiB
File Modification Date/Time     : 2021:06:21 14:45:17+02:00
File Access Date/Time           : 2021:06:21 14:55:02+02:00
File Inode Change Date/Time     : 2021:06:21 14:55:01+02:00
File Permissions                : -rw-r--r--
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 Pro
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : 14.0.1
Modify Date                     : 2021:06:15 17:59:12
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/60
F Number                        : 1.8
Exposure Program                : Program AE
ISO                             : 125
Exif Version                    : 0231
Date/Time Original              : 2021:06:15 17:59:12
Create Date                     : 2021:06:15 17:59:12
Offset Time                     : +02:00
Offset Time Original            : +02:00
Offset Time Digitized           : +02:00
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/60
Aperture Value                  : 1.8
Brightness Value                : 3.03912093
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Auto, Did not fire
Focal Length                    : 4.2 mm
Subject Area                    : 2002 1505 2213 1324
Run Time Flags                  : Valid
Run Time Value                  : 177843221492583
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
Acceleration Vector             : 0.008651109405 -0.003601103323 -1.025277733
Sub Sec Time Original           : 185
Sub Sec Time Digitized          : 185
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
Focal Length In 35mm Format     : 26 mm
Scene Capture Type              : Standard
Lens Info                       : 1.539999962-6mm f/1.8-2.4
Lens Make                       : Apple
Lens Model                      : iPhone 11 Pro back triple camera 4.25mm f/1.8
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
GPS Img Direction Ref           : True North
GPS Img Direction               : 71.31763456
GPS Dest Bearing Ref            : True North
GPS Dest Bearing                : 71.31763456
GPS Date Stamp                  : 2021:06:15
GPS Horizontal Positioning Error: 65 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)
Image Width                     : 3024
Image Height                    : 4032
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         : 2 days 1:24:03
Aperture                        : 1.8
Image Size                      : 3024x4032
Megapixels                      : 12.2
Scale Factor To 35 mm Equivalent: 6.1
Shutter Speed                   : 1/60
Create Date                     : 2021:06:15 17:59:12.185+02:00
Date/Time Original              : 2021:06:15 17:59:12.185+02:00
Modify Date                     : 2021:06:15 17:59:12+02:00
GPS Altitude                    : 255.7 m Above Sea Level
GPS Latitude                    : 49 deg 59' 50.66" N
GPS Longitude                   : 14 deg 25' 29.76" E
Circle Of Confusion             : 0.005 mm
Field Of View                   : 69.4 deg
Focal Length                    : 4.2 mm (35 mm equivalent: 26.0 mm)
GPS Position                    : 49 deg 59' 50.66" N, 14 deg 25' 29.76" E
Hyperfocal Distance             : 2.04 m
Light Value                     : 7.3
Lens ID                         : iPhone 11 Pro back triple camera 4.25mm f/1.8

损坏文件的元数据c.heic:

c.heic: ISO Media, HEIF Image HEVC Main or Main Still Picture Profile


ExifTool Version Number         : 12.26
File Name                       : c.heic
Directory                       : /Users/pepa/Downloads/imageTests/a
File Size                       : 1592 KiB
File Modification Date/Time     : 2021:06:21 14:53:11+02:00
File Access Date/Time           : 2021:06:21 14:55:02+02:00
File Inode Change Date/Time     : 2021:06:21 14:55:01+02:00
File Permissions                : -rw-r--r--
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, heic
Handler Type                    : Picture
Primary Item Reference          : 1
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Y Cb Cr Positioning             : Centered
White Balance                   : Auto
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 11 Pro
Software                        : 14.0.1
Modify Date                     : 2021:06:15 17:59:12
Exposure Time                   : 1/60
F Number                        : 1.8
Exposure Program                : Program AE
ISO                             : 125
Exif Version                    : 0231
Date/Time Original              : 2021:06:15 17:59:12
Create Date                     : 2021:06:15 17:59:12
Offset Time                     : +02:00
Offset Time Original            : +02:00
Offset Time Digitized           : +02:00
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/60
Aperture Value                  : 1.8
Brightness Value                : 3.03912093
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Auto, Did not fire
Focal Length                    : 4.2 mm
Subject Area                    : 2002 1505 2213 1324
Run Time Flags                  : Valid
Run Time Value                  : 177843221492583
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
Acceleration Vector             : 0.008651109405 -0.003601103323 -1.025277733
Sub Sec Time Original           : 185
Sub Sec Time Digitized          : 185
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
Focal Length In 35mm Format     : 26 mm
Scene Capture Type              : Standard
Lens Info                       : 1.539999962-6mm f/1.8-2.4
Lens Make                       : Apple
Lens Model                      : iPhone 11 Pro back triple camera 4.25mm f/1.8
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
GPS Img Direction Ref           : True North
GPS Img Direction               : 71.31763456
GPS Dest Bearing Ref            : True North
GPS Dest Bearing                : 71.31763456
GPS Date Stamp                  : 2021:06:15
GPS Horizontal Positioning Error: 65 m
HEVC Configuration Version      : 1
General Profile Space           : Conforming
General Tier Flag               : Main Tier
General Profile IDC             : Main Still Picture
Gen Profile Compatibility Flags : Main Still Picture, Main 10, Main
Constraint Indicator Flags      : 0 0 0 0 0 0
General Level IDC               : 180 (level 6.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              : Yes
Color Representation            : nclx 2 2 6
Image Pixel Depth               : 8 8 8
Media Data Size                 : 1629724
Media Data Offset               : 470
Run Time Since Power Up         : 2 days 1:24:03
Aperture                        : 1.8
Scale Factor To 35 mm Equivalent: 6.1
Shutter Speed                   : 1/60
Create Date                     : 2021:06:15 17:59:12.185+02:00
Date/Time Original              : 2021:06:15 17:59:12.185+02:00
Modify Date                     : 2021:06:15 17:59:12+02:00
GPS Altitude                    : 255.7 m Above Sea Level
GPS Latitude                    : 49 deg 59' 50.66" N
GPS Longitude                   : 14 deg 25' 29.76" E
Circle Of Confusion             : 0.005 mm
Field Of View                   : 69.4 deg
Focal Length                    : 4.2 mm (35 mm equivalent: 26.0 mm)
GPS Position                    : 49 deg 59' 50.66" N, 14 deg 25' 29.76" E
Hyperfocal Distance             : 2.04 m
Light Value                     : 7.3
Lens ID                         : iPhone 11 Pro back triple camera 4.25mm f/1.8

ImageMagick --版本

Version: ImageMagick 7.0.10-59 Q16 x86_64 2021-01-24 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib freetype gslib heic jng jp2 jpeg lcms lqr ltdl lzma openexr png ps tiff webp xml zlib

换句话说,每次输出 HEIC 都是损坏的输出。知道为什么吗?

升级到最新的 7.1.0 版本解决了这个问题。