Converting HEIC images with Display P3 color profile

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
psimeon
Posts: 3
Joined: 2018-06-29T12:10:43-07:00
Authentication code: 1152

Converting HEIC images with Display P3 color profile

Post by psimeon »

I am trying to convert HEIC images shot with the lastest generation of iPhones. They are in HEIC format and use the "Display P3" color profile. When I try to convert the images to JPGs the colors get washed out. The profile in the picture is an exif-profile, not an ICC profile. I assume 'convert' does not recognise this kind of profile. Is there a way to tell 'convert' to use an external icc-profile (I have a "Display P3" icc file extracted from a JPEG) and use that to interpret the image data while converting to JPGs?

I'm using the latest version of ImageMagick compiled from source on a CentOS server.

Thanks for any help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting HEIC images with Display P3 color profile

Post by fmw42 »

If the input has a profile (icc, icm), then add one -profile for the output color type.

Code: Select all

convert input -profile path/to/profile.icc output
If the input has no profile (icc, icm), then add two profiles, one for what the input color type is and one for what you want for the output

Code: Select all

convert input -profile path/to/profile1.icc -profile path/to/profile2.icc output
see http://www.imagemagick.org/script/comma ... hp#profile
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting HEIC images with Display P3 color profile

Post by snibgo »

As Fred says. ICC profiles for P3 are available from http://color.support/iccprofiles.html
snibgo's IM pages: im.snibgo.com
psimeon
Posts: 3
Joined: 2018-06-29T12:10:43-07:00
Authentication code: 1152

Re: Converting HEIC images with Display P3 color profile

Post by psimeon »

fmw42 wrote: 2018-06-29T12:42:19-07:00 If the input has no profile (icc, icm), then add two profiles, one for what the input color type is and one for what you want for the output

Code: Select all

convert input -profile path/to/profile1.icc -profile path/to/profile2.icc output
I tried to do that

Code: Select all

convert IMG_8938.HEIC -profile Display\ P3.icc -profile sRGB2014.icc IMG_8938_srgb.jpg
but it gives me totally wrong colors.

I have put the images on our server, maybe it helps if you can see the images:
http://test.olloworld.com/assets/image/ ... _8938.HEIC (original Image)
http://test.olloworld.com/assets/image/ ... G_8938.JPG (JPG sRGB created with Preview on the Mac)
http://test.olloworld.com/assets/image/ ... 938_IM.jpg (JPG from ImageMagick without profiles)
http://test.olloworld.com/assets/image/ ... 8_srgb.jpg (JPG from Image Magick with profiles)

Do I have to specify a different input color space?

Any other ideas?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting HEIC images with Display P3 color profile

Post by fmw42 »

Put double quotes around your path to the icc file. Imagemagick thinks you have two words due the space.

convert IMG_8938.HEIC -profile "Display\ P3.icc" -profile sRGB2014.icc IMG_8938_srgb.jpg
psimeon
Posts: 3
Joined: 2018-06-29T12:10:43-07:00
Authentication code: 1152

Re: Converting HEIC images with Display P3 color profile

Post by psimeon »

fmw42 wrote: 2018-06-29T15:09:41-07:00 Put double quotes around your path to the icc file. Imagemagick thinks you have two words due the space.

convert IMG_8938.HEIC -profile "Display\ P3.icc" -profile sRGB2014.icc IMG_8938_srgb.jpg
The space was escaped with the backslash.'I tried with quotes, same effect. Convert found the file, but applied in a way that gave the wrong colors.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting HEIC images with Display P3 color profile

Post by fmw42 »

Sorry, I do not have installed the HEIC delegate, so I cannot check for you. You will need one of the developers to check this for you.
loki5100
Posts: 35
Joined: 2018-02-24T14:51:41-07:00
Authentication code: 1152

Re: Converting HEIC images with Display P3 color profile

Post by loki5100 »

exactly same problem for me here :(
zkarj
Posts: 3
Joined: 2019-09-14T20:14:47-07:00
Authentication code: 1152

Re: Converting HEIC images with Display P3 color profile

Post by zkarj »

I have the opposite problem. I have JPEGs I wish to convert to HEIC. I've tried various specifications of colorspace and profile but always seem to get the same result.

An image with lots of bright colours gets blown out. Average images seem to get more contrasty. The macOS Preview App can do the conversion without this issue and I cannot see anything in the "identify" output to distinguish the magick'ed one from the Preview one.

Any thoughts on how to get the colour conversion correct?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting HEIC images with Display P3 color profile

Post by fmw42 »

What is your ImageMagick version and platform? What was your exact command line? Can you provide your input image?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting HEIC images with Display P3 color profile

Post by snibgo »

@zkarj: Can your version of IM write HEIC files?

Code: Select all

f:\web\im>%IMG7%magick -list format |grep -i HEIC
     HEIC* HEIC      r--   High Efficiency Image Format (1.4.0)
This version (v7.0.8-64 on Windows 8.1) can read HEIC, but not write it.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting HEIC images with Display P3 color profile

Post by fmw42 »

The page at https://imagemagick.org/script/formats.php, says
HEIC R Apple High efficiency Image Format HEIC requires the libheif delegate library.
So ImageMagick can only read HEIC as far as I know. Check on your system using

convert -list format

and look at the line for HEIC assuming you have installed the needed delegate library, libheif.
zkarj
Posts: 3
Joined: 2019-09-14T20:14:47-07:00
Authentication code: 1152

Re: Converting HEIC images with Display P3 color profile

Post by zkarj »

snibgo wrote: 2019-09-15T04:41:26-07:00 @zkarj: Can your version of IM write HEIC files?
Yes, it can.

HEIC* HEIC rw- High Efficiency Image Format

I can happily read and write HEIC files and they are recognisable as the same image but the colour space handling is the problem. If I convert JPG -> HEIC then the colour is essentially an "adjusted" version of the original (blue is still blue, etc, but different hue and brightness). If I convert HEIC -> JPG then everything looks identical.

But, I tried to use the montage command on some HEICs I created with another tool and the thumbs come out with a wild pinkish-red colour cast regardless of whether the output is HEIC or JPG. It seems like this is doable, I just cannot figure out how.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting HEIC images with Display P3 color profile

Post by snibgo »

In theory, this should work when the input image is sRGB with or without an embedded profile:

Code: Select all

magick in.png -profile sRGB.icc P3D5.icc out.heic
But I have no way of testing this.
snibgo's IM pages: im.snibgo.com
zkarj
Posts: 3
Joined: 2019-09-14T20:14:47-07:00
Authentication code: 1152

Re: Converting HEIC images with Display P3 color profile

Post by zkarj »

Theory is a fine thing, but when I ran the following (which I think is what you meant?) the same problem occurred.

Code: Select all

magick in.jpg -profile sRGB2014.icc -profile P3D65.icc out.heic
The key changes are specifying the -profile flag once for each profile (that's what the documentation says to do) and the slightly different profile names that are the ones I managed to find and download.
Post Reply