Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for HEIF #507

Closed
alexbilbie opened this issue Jun 6, 2017 · 136 comments
Closed

Support for HEIF #507

alexbilbie opened this issue Jun 6, 2017 · 136 comments
Labels

Comments

@alexbilbie
Copy link

@alexbilbie alexbilbie commented Jun 6, 2017

Apple have announced that all of their devices running iOS 11 and macOS 10.13 will support HEIF (High Efficiency Image File) format.

From Wikipedia:

High Efficiency Image File Format (HEIF) is a file format for individual images and image sequences. It was developed by the Moving Picture Experts Group (MPEG) and is defined by MPEG-H Part 12 (ISO/IEC 23008-12).

The HEIF specification also defines the means of storing High Efficiency Video Codec (HEVC)-encoded intra images and HEVC-encoded image sequences in which inter prediction is applied in a constrained manner.

HEIF files are compatible with the ISO Base Media File Format (ISOBMFF, ISO/IEC 14496-12) and can also include other media streams, such as timed text and audio.

There is an open source C++ encoder and decoder implementation available from here - https://github.com/nokiatech/heif.

Is there potential for ImageMagick to support this new format?

@LasseRafn
Copy link

@LasseRafn LasseRafn commented Jun 6, 2017

+1

@dlemstra dlemstra added the enhancement label Jun 6, 2017
@mikayla-grace
Copy link

@mikayla-grace mikayla-grace commented Jun 6, 2017

We'll take a look at supporting the format, however, its a low priority and may take several months. In the mean-time, ImageMagick is open source-- any user can add support for the format and create a pull request.

@rolandrabben
Copy link

@rolandrabben rolandrabben commented Jun 12, 2017

+1

2 similar comments
@leeming87v5
Copy link

@leeming87v5 leeming87v5 commented Jun 14, 2017

+1

@ganzux
Copy link

@ganzux ganzux commented Jul 21, 2017

+1

@lang1991
Copy link

@lang1991 lang1991 commented Jul 23, 2017

I think HEIF is extensively patented so it might be tricky to integrate with IM

@victorstewart
Copy link

@victorstewart victorstewart commented Jul 29, 2017

+1

3 similar comments
@mpco
Copy link

@mpco mpco commented Jul 31, 2017

+1

@iipokypatop
Copy link

@iipokypatop iipokypatop commented Aug 1, 2017

+1

@krissen
Copy link

@krissen krissen commented Aug 26, 2017

+1

@rolandrabben
Copy link

@rolandrabben rolandrabben commented Aug 31, 2017

In a couple of weeks, all HEIF will break loose. I am really surprised that no one in the ImageMagic community has jumped on this one.

@urban-warrior
Copy link
Contributor

@urban-warrior urban-warrior commented Aug 31, 2017

We were hoping you would contribute source code to the ImageMagick project to support HEIF :-).

@ericcj
Copy link

@ericcj ericcj commented Aug 31, 2017

It's complicated because iOS 11 is actually storing tiles of HEVC encoded images in a HEIF container, but there's a demo using the nokia lib to extract them all, ffmpeg to decode them and then stitching them into a single jpeg in the heiftest repo linked from https://stackoverflow.com/questions/45485622/corrupted-heic-tile-when-converting-to-jpeg and nokiatech/heif#9

we're also working on one that uses libav in nokiatech/heif@master...pushd:heiftojpeg

imagemagick already supports mpeg via ffmpeg so the HEVC part seems straightforward but it'd need to link to either nokiatech/heif or https://gpac.wp.imt.fr/2017/06/09/gpac-support-for-heif/ to extract the tiles from the HEIF

@urban-warrior
Copy link
Contributor

@urban-warrior urban-warrior commented Aug 31, 2017

The GPAC web site discusses how to create a HEIC file but does not discuss how to extract the images / tiles from an existing HEIC file. Do you have the MP4Box command-line parameters to extract the images / tiles?

@ericcj
Copy link

@ericcj ericcj commented Aug 31, 2017

It seemed like this should be it but not sure why it's invalid...seems to expect a movie. The Nokia one actually works

$ ~/gpac/bin/gcc/MP4Box -info ~/test_001.heic
ICC colour profile not supported
ICC colour profile not supported
Root Meta type: "pict" - 52 resource item(s)
Primary Item - ID 49
Item #1 - ID 1 - Name:
Item #2 - ID 2 - Name:
...
Item #51 - ID 51 - Name:
File has no movie (moov) - static data container

$ ~/gpac/bin/gcc/MP4Box -dump-item 1:path=item1.hevc ~/test_001.heic

$ ffmpeg -i item1.hevc -frames:v 1 -vsync vfr -q:v 1 -an item1.bmp
item1.hevc: Invalid data found when processing input
@eriken
Copy link

@eriken eriken commented Sep 1, 2017

An issue as far as performance goes, is decoding all the tiles. Currently I am running a ffmpeg batch job to decode all the tiles. One can do this concurrently ofcourse, but I would argue it would be better to stitch all the hevc tiles together and then decode the frame in one execution.

@modest
Copy link

@modest modest commented Sep 1, 2017

As far as code licensing goes, Nokia's HEIF code is unusable by most teams; it is incompatible with open source licenses and is explicitly limited to non-commercial use. The GPAC + ffmpeg route is more promising.

@agharib
Copy link

@agharib agharib commented Sep 2, 2017

Does anyone know if GPAC supports opening heic files? I also see just creating on the site.

@kode54
Copy link

@kode54 kode54 commented Sep 8, 2017

The info on creating should demonstrate which atoms or atom trees should be extracted to produce the tiles. Also, I doubt you can just reconstruct the tiles and decode them all in one go, since they're independent HEVC frames. What you can do, however, is OpenMP batch the frame decodes to different instances of the HEVC decoder, to take advantage of multi-core processors. That, and reducing the memory footprint of the encoder, is probably Apple's reason for opting to encode their on-device files as batches of 256x256 tiles, or smaller possibly non-rectangular tiles for the right/bottom edges, for images that are not an even multiple of 256 in width or height.

E: And maybe clean up these +1 posts and ask that their posters kindly vote with the emoji thumbs up on the opening post, a feature that Github has had for over a year now?

@knopa
Copy link

@knopa knopa commented Sep 11, 2017

Very strange why there is no easy way to convert heif to jpg

@kode54
Copy link

@kode54 kode54 commented Sep 11, 2017

If you're using a Mac, you can use sips to convert to or from HEIF or JPEG or PNG or even TIFF. Or if you prefer the GUI, you can use the Preview app. Both on High Sierra, though.

Too bad you're left out in the cold pretty much everywhere else.

@knopa
Copy link

@knopa knopa commented Sep 12, 2017

Well, I need to do it on windows server

@liuziangexit
Copy link

@liuziangexit liuziangexit commented Sep 18, 2017

well, i wrote a program that support iOS 11's HEIF File, https://github.com/liuziangexit/HEIF-Utility

@swindi-de
Copy link

@swindi-de swindi-de commented Sep 18, 2017

+1

@deweydb
Copy link

@deweydb deweydb commented Sep 18, 2017

I have tried both @liuziangexit's program and @kode54's suggestion to use sips, neither worked. The former gives me an error saying "unable to open file", while the later outputs the path name of the source file and the path name of the destination file to the terminal, but does not generate an output converted image.

eg:
sips --setProperty format jpeg IMG_5923.HEIC --out test.jpg

Outputs the following to terminal without generating an image:

/Users/deweydb/Dev/HeicConversion/IMG_5923.HEIC
/Users/deweydb/Dev/HeicConversion/test.jpg

does not work. but perhaps i'm using the wrong flags?

@kode54
Copy link

@kode54 kode54 commented Sep 18, 2017

I was mistaken. sips does not appear to support HEIC. Preview does, though, but that's a GUI app.

@ericcj
Copy link

@ericcj ericcj commented Sep 18, 2017

@urban-warrior @modest @agharib FYI the MP4Box/ffmpeg invocation I gave above now appears to work after they fixed a bug in master: gpac/gpac#901

@kode54
Copy link

@kode54 kode54 commented Sep 18, 2017

I see everybody wants to export HEIC to JPEG. I'm looking more for creating HEIC files. Including creating tiled images similar to what the phone creates, and also creating animated HEIC files from GIF and APNG files.

@themaddoctor
Copy link

@themaddoctor themaddoctor commented Feb 1, 2018

@ennss
Copy link

@ennss ennss commented Feb 2, 2018

Thanks IM devs,
The .heic support works on cygwin once you get libde265 working:
strukturag/libde265#161
(I tried a sample iphone image file, with "convert" and "identify" - some samples from nokiatech.github.io/heif/examples.html don't seem to be supported yet.)

@mojidabckuu
Copy link

@mojidabckuu mojidabckuu commented Feb 6, 2018

After installing from source it works perfectly to convert but unfortunately identify doesn't return anything. What I am doing wrong?
Is it ok that --version doesn't list HEIC delegate?

@ennss
Copy link

@ennss ennss commented Feb 7, 2018

On further testing, I get the same result - convert works, but no heic delegate listed and nothing returned by identify. I'm guessing that it's "normal" for the current (very new) heic support implementation...

@themaddoctor
Copy link

@themaddoctor themaddoctor commented Feb 7, 2018

@torlin
Copy link

@torlin torlin commented Feb 7, 2018

I get the same result that convert works but invert returns nothing, too. I am sure that I have installed libde265, otherwise convert could not work.

@toshic
Copy link

@toshic toshic commented Feb 8, 2018

I guess it could be because I didn't implement ping method. Do you test in IM7 or IM6.8 ?

@torlin
Copy link

@torlin torlin commented Feb 8, 2018

I test this in the newest official release of IM6.9.9-34, which has included the patch heic.c.

@ennss
Copy link

@ennss ennss commented Feb 8, 2018

Ok, thanks toshic - I'm sure that's exactly it. No ping method. I've been using the latest dev release 7.0.7-22. Thanks very much for your development of the HEIF support!

@dlemstra
Copy link
Member

@dlemstra dlemstra commented Feb 8, 2018

I will go through the decoder with a comb this weekend and make sure we also have ping support.

@dlemstra dlemstra removed the up for grabs label Feb 8, 2018
dlemstra added a commit that referenced this issue Feb 8, 2018
dlemstra added a commit that referenced this issue Feb 8, 2018
@dlemstra dlemstra closed this Feb 17, 2018
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Feb 24, 2018
2018-01-22  7.0.7-22 Cristy  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.0-22, GIT revision 22391:e8be814f1:20180122.

2018-01-06  7.0.7-22 Cristy  <quetzlzacatenango@image...>
  * Support aspect ratio geometry, e.g. -crop 3:2.
  * Add support for reading the HEIC image format (reference
    ImageMagick/ImageMagick#507).
  * Fixed numerous memory leaks, credit to OSS Fuzz.
@mattwaltbriggs
Copy link

@mattwaltbriggs mattwaltbriggs commented Mar 8, 2018

On MacOS 10.13.3 using ImageMagick installed via homebrew, this doesn't work:
`Ironside:Downloads dalek$ magick camel.heic sample_test.jpg

magick: no decode delegate for this image format 'HEIC' @ error/constitute.c/ReadImage/509.

Ironside:Downloads dalek$ magick --version

Version: ImageMagick 7.0.7-25 Q16 x86_64 2018-03-04 http://www.imagemagick.org

Copyright: © 1999-2018 ImageMagick Studio LLC

License: http://www.imagemagick.org/script/license.php

Features: Cipher DPC HDRI Modules

Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib`

@MarcelMitzkus
Copy link

@MarcelMitzkus MarcelMitzkus commented Mar 9, 2018

@mattwaltbriggs I'm facing the same issue with this version under ubuntu. Libde256 is already installed.

@MarcelMitzkus
Copy link

@MarcelMitzkus MarcelMitzkus commented Mar 9, 2018

@toshic I'm facing a problem with your version build from the master branch.
I downloaded the version from https://github.com/toshic/ImageMagick/archive/master.zip
After building the version i tried to convert a heic file but it's not working.
Message:
magick: no decode delegate for this image format 'HEIC' @ error/constitute.c/ReadImage/509.

Libde256-dev is installed. My system is a ubuntu system.
It's weired because a few weeks ago i already build a version from your branch and it was working.

@themaddoctor
Copy link

@themaddoctor themaddoctor commented Mar 9, 2018

@Shinta
Copy link

@Shinta Shinta commented Apr 20, 2018

Getting the same problem here with Ubuntu 14, using @toshic repo:

./configure reports that HEIC will be included:

Host system type: x86_64-pc-linux-gnu
  Build system type: x86_64-pc-linux-gnu

                 Option                        Value
  ------------------------------------------------------------------------------
  Shared libraries  --enable-shared=yes		yes
  Static libraries  --enable-static=yes		yes
  Module support    --with-modules=no		no
  GNU ld            --with-gnu-ld=yes		yes
  Quantum depth     --with-quantum-depth=16	16
  High Dynamic Range Imagery
                    --enable-hdri=yes		yes

  Install documentation:			yes

  Delegate Library Configuration:
  BZLIB             --with-bzlib=yes		yes
  Autotrace         --with-autotrace=no		no
  DJVU              --with-djvu=yes		yes
  DPS               --with-dps=yes		no
  FFTW              --with-fftw=yes		yes
  FLIF              --with-flif=yes		no
  FlashPIX          --with-fpx=yes		no
  FontConfig        --with-fontconfig=yes	yes
  FreeType          --with-freetype=yes		yes
  Ghostscript lib   --with-gslib=no		no
  Graphviz          --with-gvc=yes		no
  HEIC              --with-heic=yes		yes
  JBIG              --with-jbig=yes		yes
  JPEG v1           --with-jpeg=yes		yes
  LCMS              --with-lcms=yes		yes
  LQR               --with-lqr=yes		yes
  LTDL              --with-ltdl=yes		no
  LZMA              --with-lzma=yes		yes
  Magick++          --with-magick-plus-plus=yes	yes
  OpenEXR           --with-openexr=yes		yes
  OpenJP2           --with-openjp2=yes		no
  PANGO             --with-pango=yes		yes
  PERL              --with-perl=no		no
  PNG               --with-png=yes		yes
  RAQM              --with-raqm=yes		no
  RAW               --with-raw=yes		no
  RSVG              --with-rsvg=no		no
  TIFF              --with-tiff=yes		yes
  WEBP              --with-webp=yes		no
  WMF               --with-wmf=yes		yes
  X11               --with-x=			yes
  XML               --with-xml=yes		yes
  ZLIB              --with-zlib=yes		yes

  Delegate Program Configuration:
  GhostPCL          None				pcl6 (unknown)
  GhostXPS          None				gxps (unknown)
  Ghostscript       None				gs (9.10)

  Font Configuration:
  Apple fonts       --with-apple-font-dir=default	
  Dejavu fonts      --with-dejavu-font-dir=default	none
  Ghostscript fonts --with-gs-font-dir=default	/usr/share/fonts/type1/gsfonts/
  URW-base35 fonts  --with-urw-base35-font-dir=default  
  Windows fonts     --with-windows-font-dir=default	none

  X11 Configuration:
        X_CFLAGS        = 
        X_PRE_LIBS      =  -lSM -lICE
        X_LIBS          = 
        X_EXTRA_LIBS    = 

  Options used to compile and link:
    PREFIX          = /usr/local
    EXEC-PREFIX     = /usr/local
    VERSION         = 7.0.7
    CC              = gcc -std=gnu99 -std=gnu99
    CFLAGS          = -I/usr/include/libxml2   -I/usr/include/libpng12    -pthread -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -pthread -I/usr/include/OpenEXR     -I/usr/include/lqr-1 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include       -I/usr/include/freetype2   -I/usr/include/freetype2   -pthread        -fopenmp -g -O2 -Wall -mtune=core-avx2 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
    CPPFLAGS        =   -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 
    PCFLAGS         = 
    DEFS            = -DHAVE_CONFIG_H
    LDFLAGS         =  
    LIBS            = 
    CXX             = g++
    CXXFLAGS        = -g -O2 -pthread
    FEATURES        = DPC HDRI Cipher OpenMP
    DELEGATES       = bzlib djvu mpeg fftw fontconfig freetype heic jbig jng jpeg lcms lqr lzma openexr pango png ps tiff wmf x xml zlib
==============================================================================

But:

ubuntu@local:~$ /usr/local/bin/identify --version
Version: ImageMagick 7.0.7-23 Q16 x86_64 2018-04-20 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP 
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr lzma openexr pangocairo png tiff wmf x xml zlib

No HEIC support at the end.

@bploetz
Copy link

@bploetz bploetz commented Jun 28, 2018

This might be a stupid question, but should this work on Alpine Linux where we don't have libde256, but instead have the x265 and x265-dev packages?

opt/picbox-api/spec/fixtures # identify -version
Version: ImageMagick 7.0.7-11 Q16 x86_64 2017-11-15 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP 
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jpeg lcms ltdl pangocairo png ps rsvg tiff webp xml zlib

Neither identify nor convert work. Do I need to use an Ubuntu based container so I can get libde256 for this to work?

@toshic
Copy link

@toshic toshic commented Jun 28, 2018

Unfortunately, it's not possible for 2 reasons:
The first, and the main one: libx265 is encoder, there is no decoder code in that library.
The second is that there is no sort of common API, every library implements it's own version.

You can build libde265 from sources if you want to use it on Alpine.

@bploetz
Copy link

@bploetz bploetz commented Jun 28, 2018

Ah, ok. Thanks @toshic.

@b0o
Copy link

@b0o b0o commented Oct 3, 2018

I'm testing HEIC support with the macOS Mojave dynamic wallpaper, which should contain a sequence of 16 images. convert Mojave.heic Mojave.jpg only gets me the first image in the sequence. How would I extract all of them to individual files?

@dlemstra
Copy link
Member

@dlemstra dlemstra commented Oct 4, 2018

@b0o Could you open a new issue for that question instead of hijacking this one?

@ImageMagick ImageMagick locked as off topic and limited conversation to collaborators Oct 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet