Skip Menu |
 

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 128445
Status: open
Priority: 0/
Queue: Imager

People
Owner: Nobody in particular
Requestors: dcantrell [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Please add support for HEIC/HEIF images
Possibly by wrapping around libheif <https://github.com/strukturag/libheif>
CC: ;
Subject: Re: [rt.cpan.org #128445] Please add support for HEIC/HEIF images
Date: Thu, 7 Feb 2019 08:49:57 +1100
To: David Cantrell via RT <bug-Imager [...] rt.cpan.org>
From: Tony Cook <tony [...] develop-help.com>
Download (untitled) / with headers
text/plain 957b
On Wed, Feb 06, 2019 at 08:07:02AM -0500, David Cantrell via RT wrote: Show quoted text
> Wed Feb 06 08:07:01 2019: Request 128445 was acted upon. > Transaction: Ticket created by DCANTRELL > Queue: Imager > Subject: Please add support for HEIC/HEIF images > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: dcantrell@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=128445 > > > > Possibly by wrapping around libheif <https://github.com/strukturag/libheif>
Do you have any idea where I could get the file format specification cheaply? For C11 I have the final draft, but I haven't seen anything similar for HEIF (aka ISO/IEC DIS 23008-12). Since HEIF is a container format[1], libheif would work for .heic (purely H.265 encoding), but it doesn't appear to support other encodings. Tony [1] based on Wikipedia https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format
CC: ;
Subject: Re: [rt.cpan.org #128445] Please add support for HEIC/HEIF images
Date: Thu, 7 Feb 2019 10:03:22 +1100
To: David Cantrell via RT <bug-Imager [...] rt.cpan.org>
From: Tony Cook <tony [...] develop-help.com>
Download (untitled) / with headers
text/plain 308b
On Wed, Feb 06, 2019 at 05:22:40PM -0500, David Cantrell via RT wrote: Show quoted text
Thanks, that works.
CC: ;
Subject: Re: [rt.cpan.org #128445] Please add support for HEIC/HEIF images
Date: Sat, 9 Feb 2019 17:56:34 +1100
To: David Cantrell via RT <bug-Imager [...] rt.cpan.org>
From: Tony Cook <tony [...] develop-help.com>
Download (untitled) / with headers
text/plain 870b
On Wed, Feb 06, 2019 at 08:07:02AM -0500, David Cantrell via RT wrote: Show quoted text
> Wed Feb 06 08:07:01 2019: Request 128445 was acted upon. > Transaction: Ticket created by DCANTRELL > Queue: Imager > Subject: Please add support for HEIC/HEIF images > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: dcantrell@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=128445 > > > > Possibly by wrapping around libheif <https://github.com/strukturag/libheif>
Have a play with: https://github.com/tonycoz/imager-file-heif It requires that libheif, libde265 and libx265 all be installed, along with their development headers. I've only tested detection with pkg-config, so you may need to set PKG_CONFIG_PATH so it points at the directory containing the .pc files for those libraries. Tony
Download (untitled) / with headers
text/plain 1.4k
Show quoted text
Thanks! Using the libraries and headers from debian-testing, looks like it at least mostly works. I could read a HEIC file from an iPhone's camera, scale it, and save it back out as another format, which is the specific use-case we have at work. Reading the same original file, scaling it, and saving it back out as heic/heif resulted in something that Preview.app on a Mac couldn't read, but Imager::File::HEIF *could* read it and convert it to another format which Preview could read, so I'm inclined to think that that may be a limitation in Preview.app only being able to decode the particular subset of files generated by other Apple software. $ perl -Mblib -MImager -e '$foo=Imager->new(file=>"IMG_2781.HEIC",type=>"heif"); $thumb=$foo->scale(scalefactor=>0.3);$thumb->write(file=>"foo.tga")' gives the expected results $ perl -Mblib -MImager -e '$foo=Imager->new(file=>"IMG_2781.HEIC",type=>"heif"); $thumb=$foo->scale(scalefactor=>0.3);$thumb->write(file=>"foo.heif")' gives a file that Preview.app can't read, but feeding the output from that into ... $ perl -Mblib -MImager -e '$foo=Imager->new(file=>"foo.heif",type=>"heif"); $thumb=$foo->scale(scalefactor=>0.3);$thumb->write(file=>"foo.tga")' again gives the expected results, a scaled image that Preview can decode In case it helps figure out what Apple are doing (if, indeed, you care to work around their limitations!) I've attached the original input file that I used
Subject: IMG_2781.HEIC
Download IMG_2781.HEIC
image/heic 966.6k
IMG_2781.HEIC
CC: ;
Subject: Re: [rt.cpan.org #128445] Please add support for HEIC/HEIF images
Date: Tue, 12 Feb 2019 08:47:43 +1100
To: David Cantrell via RT <bug-Imager [...] rt.cpan.org>
From: Tony Cook <tony [...] develop-help.com>
On Mon, Feb 11, 2019 at 11:02:00AM -0500, David Cantrell via RT wrote: Show quoted text
> Queue: Imager > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=128445 > >
> > Have a play with: > > > > https://github.com/tonycoz/imager-file-heif
> > Thanks! > > Using the libraries and headers from debian-testing, looks like it at least mostly works. > > I could read a HEIC file from an iPhone's camera, scale it, and save it back out as another format, which is the specific use-case we have at work. > > Reading the same original file, scaling it, and saving it back out as heic/heif resulted in something that Preview.app on a Mac couldn't read, but Imager::File::HEIF *could* read it and convert it to another format which Preview could read, so I'm inclined to think that that may be a limitation in Preview.app only being able to decode the particular subset of files generated by other Apple software. > > $ perl -Mblib -MImager -e '$foo=Imager->new(file=>"IMG_2781.HEIC",type=>"heif"); $thumb=$foo->scale(scalefactor=>0.3);$thumb->write(file=>"foo.tga")' > > gives the expected results > > $ perl -Mblib -MImager -e '$foo=Imager->new(file=>"IMG_2781.HEIC",type=>"heif"); $thumb=$foo->scale(scalefactor=>0.3);$thumb->write(file=>"foo.heif")' > > gives a file that Preview.app can't read, but feeding the output from that into ... >
Preview.app could read the original and the output here, even on my older 10.13.6 OS X (the hardware is too old to upgrade.) Windows 10 wanted me to pay for a codec to open it in Windows 10 Photos. GIMP opened it fine, but I think that's using libheif. Show quoted text
> $ perl -Mblib -MImager -e '$foo=Imager->new(file=>"foo.heif",type=>"heif"); $thumb=$foo->scale(scalefactor=>0.3);$thumb->write(file=>"foo.tga")' > > again gives the expected results, a scaled image that Preview can decode > > In case it helps figure out what Apple are doing (if, indeed, you care to work around their limitations!) I've attached the original input file that I used
Can you send me the scaled foo.heif? I'm using libheif out of git, so maybe something has been fixed there. Tony
CC: ;
Subject: Re: [rt.cpan.org #128445] Please add support for HEIC/HEIF images
Date: Tue, 12 Feb 2019 09:35:28 +1100
To: "tony [...] develop-help.com via RT" <bug-Imager [...] rt.cpan.org>
From: Tony Cook <tony [...] develop-help.com>
Download (untitled) / with headers
text/plain 382b
On Mon, Feb 11, 2019 at 04:48:02PM -0500, tony@develop-help.com via RT wrote: Show quoted text
> Can you send me the scaled foo.heif? > > I'm using libheif out of git, so maybe something has been fixed there.
Also, can you try saving the scaled result as a PNG, using the heif-enc example bundled with libheif to produce a .heif file and try that in Preview? heif-enc -o foo.heif foo.png Tony
Show quoted text
> Can you send me the scaled foo.heif?
Attached
Subject: foo.heif
Download foo.heif
image/heif 493.5k
foo.heif
Download (untitled) / with headers
text/plain 500b
Show quoted text
> Also, can you try saving the scaled result as a PNG, using the > heif-enc example bundled with libheif to produce a .heif file and try > that in Preview? > > heif-enc -o foo.heif foo.png
Preview.app can read the results, and the file is considerably smaller than that produced by Imager (but maybe that's just down to different default compression settings). The especially interesting bit, though, is that the png is 1210x907 but heif-enc produces a 1210x906 file. I'm using libheif 1.3.2-1+b1
Subject: foo.png
Download foo.png
image/png 1.3m
foo.png
Subject: foo.png.heif
Download foo.png.heif
image/heif 153.1k
foo.png.heif
Download (untitled) / with headers
text/plain 779b
On Tue Feb 12 10:08:10 2019, DCANTRELL wrote: Show quoted text
> > Also, can you try saving the scaled result as a PNG, using the > > heif-enc example bundled with libheif to produce a .heif file and try > > that in Preview? > > > > heif-enc -o foo.heif foo.png
> > Preview.app can read the results, and the file is considerably smaller > than that produced by Imager (but maybe that's just down to different > default compression settings). > > The especially interesting bit, though, is that the png is 1210x907 > but heif-enc produces a 1210x906 file. > > I'm using libheif 1.3.2-1+b1
Please try Imager::File::HEIF from github https://github.com/tonycoz/imager-file-heif when tested with foo.png, Imager::File::HEIF and heif-enc now produce the exact same file (with the defaults.) Tony


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.