processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6.03k stars 1.5k forks source link

eimp:convert fails in container since ejabberd 20.12 #4023

Open badlop opened 1 year ago

badlop commented 1 year ago

It seems image conversion (provided by eimp) is broken in the containers (both ecs and ejabberd) since the ejabberd 20.12.

How to reproduce: start ejabberd in live mode, and run those calls in the erlang console. This is the desired output:

eimp:supported_formats().
[webp,jpeg,png,gif]

os:cmd("wget https://github.com/processone/eimp/raw/master/test/img.jpeg -O /tmp/img.jpeg").

eimp:convert(element(2,file:read_file("/tmp/img.jpeg")), png, []).
{ok,<<137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,
      4,0,0,0,3,4,8,2,0,...>>}

The feature works correctly when ejabberd is compiled from source code using rebar3:

./autogen.sh
./configure \
    --with-rebar=`which rebar3` \
    --enable-all \
    --disable-elixir
make
make relive
...
[webp,jpeg,png,gif]
{ok,<<137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,
      4,0,0,0,3,4,8,2,0,...>>}

Also works when using mix to build an OTP release (like the containers do):

./autogen.sh
./configure --with-rebar=mix --enable-all
make deps
make rel
cp _build/prod/ejabberd-23.1.83.tar.gz /tmp
cd /tmp
mkdir ee
tar -xzvf ejabberd-23.1.83.tar.gz -C ee
cd ee
./bin/ejabberdctl live
...
[webp,jpeg,png,gif]
{ok,<<137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,
      4,0,0,0,3,4,8,2,0,...>>}

The feature also works correctly using ecs container 20.07:

docker run -it ejabberd/ecs:20.07 live
...
[webp,jpeg,png,gif]
{ok,<<137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,
      4,0,0,0,3,4,8,2,0,...>>}

However, in ecs container 20.12 and newer, and also in the alternate ejabberd container, it fails:

docker run -it ejabberd/ecs:20.12 live
...
[webp,jpeg,png,gif]
{error,unsupported_format}

When looking at the binary installers, that call fails with a different error message:

eimp:supported_formats().
[webp,jpeg,png,gif]

eimp:convert(element(2,file:read_file("/tmp/img.jpeg")), png, []).
{error,decode_failure}

Looking at the changes in ejabberd source code between 20.07 and 20.12, maybe the relevant changes was the update from eimp 1.0.17 to 1.0.18, more specifically this commit https://github.com/processone/eimp/commit/37dcd22af9e03022417a7b340b567c6ad00cacbd