elixir-image / image

Image processing for Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot write heic images

dmitriid opened this issue · comments

Note: this might only true for my development setup which is running in Windows WSL.

System info

> uname -a
Linux MyMachine 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

> elixir -v
Erlang/OTP 25 [erts-13.1.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]

Elixir 1.14.3 (compiled with Erlang/OTP 25)

Image:

{:image, "~> 0.36.2"}
> Image.vips_version()
{:ok, %Version{major: 8, minor: 14, patch: 2}}

Issue

Any .heic file. Sample ones from here also exhibit this behaviour

> {:ok, image} = Image.open("samples/sample1.heic")
{:ok, %Vix.Vips.Image{ref: #Reference<0.1626898918.4189716507.89896>}}
> Image.height(image)
960
> Image.width(image) 
1440



> Image.write(image, "samples/new_image.heic")
{:error, "Failed to write VipsImage to file"}

> Image.write(image, "samples/new_image.png")            
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 0
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 1
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 2
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 3
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 4
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 5
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 6
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 7
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 8
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 9
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 10
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 11
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 12
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 13
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 14
(process:2983): VIPS-WARNING **: 19:10:42.121: error in tile 0 x 15
{:error, "Failed to write VipsImage to file"}

In all cases Image produces a 0 byte file, and fails to write

I've found a function that lets me determine if the error was related to a file saver for a given file type wasn't configured. That will help improve the error message at least so that's my next step. I'm confused by the .png file example with empty tiles.

I've been all over the place on this issue, apologies, travel schedule is challenging at the moment. Would you consider running the following from your shell?

kip@Kips-MacBook-Pro image % vips -config | grep VipsForeignSaveHeifFile
VipsForeignSaveHeifFile

If you get the same return then it indicated that HEIF save should be supported. If not - then libvips wasn't built with heif support.

The release of libvips doesn't tell you everything - there are many build time options and not all build systems, repositories or distributions include all the components. So it's important to check.

Sorry for a long reply, life intervened as well :) I want to add that this is not a pressing issue, so don't worry if you don't have the time to look into it. Image is amazing!

It looks like I never installed vips, and Image just worked out of the box with pre-built binaries I suppose.

> vips -config | grep VipsForeignSaveHeifFile

Command 'vips' not found, but can be installed with:

sudo apt install libvips-tools

And if I install vips, it doesn't come with HEIF support either. So that's the culprit!

I'm confused by the .png file example with empty tiles.

Yeah, this one is strange.

I'm closing this for now because I believe the issue arise because the build of libvips didn't have libheif included. Of course please re-open the issue if I've misunderstood the issues.