strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.71k stars 298 forks source link

heif-enc 1.14.0 cannot use PNG as input #751

Closed chovanecm closed 1 year ago

chovanecm commented 1 year ago

Hi, since heif-enc 1.14.0, the output produced by heif-enc for PNG input are broken files. Example png and output: png.zip

heif-enc -q 60 -v test.png

I've tried different PNG files produced by different apps (which had worked with previous versions of libheif) as well as different ways to view the HEIC files produced but none of them works.

Any ideas? Thank you

farindk commented 1 year ago

I have no problems viewing the heif in your png.zip archive. Which software did you try to show the heif file?

chovanecm commented 1 year ago

The built-in Windows image viewer and XnView MP. Now I've also tried copying the file to my iPhone but it does not load the image either (I only see "test HEIF image 2kB" instead of the image content). Which software do you use?

farindk commented 1 year ago

The image has a resolution of 394x141. It might be that those viewers have problems with the odd image height. Could you try again with an image with even width and height?

chovanecm commented 1 year ago

TMP.zip Capture

There is an improvement but both Windows and iPhone render the image in wrong dimensions. And XnView MP crashes when trying to preview the file (in both cases).

farindk commented 1 year ago

Seems to confirm that it's a problem of the viewers. My guess is that they were only tested with the iPhone images, which always use tiled images. (Maybe that's the reason your image looks square, as the tiles in iPhone images are usually also square.)

As the encoded files themselves seem to be fine, I currently don't see the need to take any action on this from my side.

chovanecm commented 1 year ago

TMP2.zip But if I use JPG instead of PNG as a source, the output is readable by both Windows and iPhone.

Perhaps is this the problem? Look at the image dimensions:

ntbthinkpad:/mnt/c/Users/Martin/Desktop/TMP$ heif-info Untitled-from-JPG.heic
MIME type: image/heic
main brand: heic
compatible brands: mif1, heic, miaf

image: 284x120 (id=1), primary
  color profile: no
  alpha channel: no
  depth channel: no
metadata:
  Exif: 86 bytes
ntbthinkpad:/mnt/c/Users/Martin/Desktop/TMP$ heif-info Untitled-from-PNG.heic
MIME type: image/heic
main brand: heic
compatible brands: mif1, heic, miaf

image: 120x284 (id=1), primary
  color profile: no
  alpha channel: no
  depth channel: no
metadata:
  none
farindk commented 1 year ago

I see. Ok, you might be affected by a bug that was fixed here: 6208c4e32534af647f0d171ed5bdedff770eee3b. This is in the current master branch and will be included in 1.4.1. Please check whether your problem is solved already in the current version from the master branch (current tip: 643ca81c20b065bf9eac2e6d86eaef5da44d0699).

chovanecm commented 1 year ago

Thanks a lot, you are right. The issue seems fixed in the latest version both for even and odd image sizes. 👍

farindk commented 1 year ago

Thanks for helping tracking this down. I'll release v1.4.1 in the coming days.