Page 1 of 1

Converting HEIC images with Display P3 color profile

Posted: 2018-06-29T12:22:49-07:00
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.

Re: Converting HEIC images with Display P3 color profile

Posted: 2018-06-29T12:42:19-07:00
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

Re: Converting HEIC images with Display P3 color profile

Posted: 2018-06-29T13:16:25-07:00
by snibgo
As Fred says. ICC profiles for P3 are available from http://color.support/iccprofiles.html

Re: Converting HEIC images with Display P3 color profile

Posted: 2018-06-29T14:54:59-07:00
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?

Re: Converting HEIC images with Display P3 color profile

Posted: 2018-06-29T15:09:41-07:00
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

Re: Converting HEIC images with Display P3 color profile

Posted: 2018-06-30T14:16:24-07:00
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.

Re: Converting HEIC images with Display P3 color profile

Posted: 2018-06-30T14:40:46-07:00
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.

Re: Converting HEIC images with Display P3 color profile

Posted: 2019-05-04T14:11:29-07:00
by loki5100
exactly same problem for me here :(

Re: Converting HEIC images with Display P3 color profile

Posted: 2019-09-14T20:19:36-07:00
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?

Re: Converting HEIC images with Display P3 color profile

Posted: 2019-09-14T23:03:42-07:00
by fmw42
What is your ImageMagick version and platform? What was your exact command line? Can you provide your input image?

Re: Converting HEIC images with Display P3 color profile

Posted: 2019-09-15T04:41:26-07:00
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.

Re: Converting HEIC images with Display P3 color profile

Posted: 2019-09-15T11:22:41-07:00
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.

Re: Converting HEIC images with Display P3 color profile

Posted: 2019-09-18T01:48:33-07:00
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.

Re: Converting HEIC images with Display P3 color profile

Posted: 2019-09-18T05:57:54-07:00
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.

Re: Converting HEIC images with Display P3 color profile

Posted: 2019-09-20T20:44:32-07:00
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.