aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac9
-rw-r--r--ejabberd.yml.example5
-rw-r--r--rebar.config5
-rw-r--r--src/ejabberd_app.erl10
-rw-r--r--src/misc.erl8
-rw-r--r--src/mod_avatar.erl67
-rw-r--r--src/mod_http_upload.erl28
-rw-r--r--vars.config.in1
8 files changed, 40 insertions, 93 deletions
diff --git a/configure.ac b/configure.ac
index 17d32ac18..f09287ed0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -244,14 +244,6 @@ AC_ARG_ENABLE(sip,
*) AC_MSG_ERROR(bad value ${enableval} for --enable-sip) ;;
esac],[if test "x$sip" = "x"; then sip=false; fi])
-AC_ARG_ENABLE(graphics,
-[AC_HELP_STRING([--enable-graphics], [enable support for graphic images manipulation (default: yes)])],
-[case "${enableval}" in
- yes) graphics=true ;;
- no) graphics=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-graphics) ;;
-esac],[if test "x$graphics" = "x"; then graphics=true; fi])
-
AC_CONFIG_FILES([Makefile
vars.config
src/ejabberd.app.src])
@@ -297,7 +289,6 @@ AC_SUBST(iconv)
AC_SUBST(stun)
AC_SUBST(sip)
AC_SUBST(debug)
-AC_SUBST(graphics)
AC_SUBST(tools)
AC_SUBST(latest_deps)
AC_SUBST(system_deps)
diff --git a/ejabberd.yml.example b/ejabberd.yml.example
index 4fea180e6..49506ed9c 100644
--- a/ejabberd.yml.example
+++ b/ejabberd.yml.example
@@ -818,10 +818,7 @@ modules:
mod_vcard:
search: false
mod_vcard_xupdate: {}
- ## Convert all avatars posted by Android clients from WebP to JPEG
- ## mod_avatar: # this module needs compile option --enable-graphics
- ## convert:
- ## webp: jpeg
+ mod_avatar: {}
mod_version: {}
mod_stream_mgmt: {}
## Non-SASL Authentication (XEP-0078) is now disabled by default
diff --git a/rebar.config b/rebar.config
index e852bf430..0b40ade57 100644
--- a/rebar.config
+++ b/rebar.config
@@ -32,6 +32,7 @@
{luerl, ".*", {git, "https://github.com/rvirding/luerl", {tag, "v0.2"}}},
{jose, ".*", {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.8.4"}}},
{fs, ".*", {git, "https://github.com/synrc/fs", "bed9467"}},
+ {eimp, ".*", {git, "https://github.com/processone/eimp", "4ba6363"}},
{if_var_true, stun, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.20"}}}},
{if_var_true, sip, {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.21"}}}},
{if_var_true, mysql, {p1_mysql, ".*", {git, "https://github.com/processone/p1_mysql",
@@ -46,7 +47,6 @@
{tag, "1.0.3"}}}},
{if_var_true, riak, {riakc, ".*", {git, "https://github.com/processone/riak-erlang-client",
{tag, {if_version_above, "19", "develop", "2.5.3"}}}}},
- {if_var_true, graphics, {eimp, ".*", {git, "https://github.com/processone/eimp", {tag, "1.0.2"}}}},
%% Elixir support, needed to run tests
{if_var_true, elixir, {elixir, ".*", {git, "https://github.com/elixir-lang/elixir",
{tag, {if_version_above, "17", "v1.4.4", "v1.1.1"}}}}},
@@ -93,7 +93,6 @@
{if_var_true, debug, debug_info},
{if_var_true, sip, {d, 'SIP'}},
{if_var_true, stun, {d, 'STUN'}},
- {if_var_true, graphics, {d, 'GRAPHICS'}},
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
{if_var_match, db_type, mssql, {d, 'mssql'}},
{if_var_true, elixir, {d, 'ELIXIR_ENABLED'}},
@@ -158,11 +157,11 @@
{post_hook_configure, [{"fast_tls", []},
{"stringprep", []},
{"fast_yaml", []},
+ {"eimp", []},
{if_var_true, sip, {"esip", []}},
{"fast_xml", [{if_var_true, full_xml, "--enable-full-xml"}]},
{if_var_true, pam, {"epam", []}},
{if_var_true, zlib, {"ezlib", []}},
- {if_var_true, graphics, {"eimp", []}},
{if_var_true, iconv, {"iconv", []}}]}.
{port_env, [{"CFLAGS", "-g -O2 -Wall"}]}.
diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl
index 0790c4168..a7e03d990 100644
--- a/src/ejabberd_app.erl
+++ b/src/ejabberd_app.erl
@@ -150,7 +150,7 @@ start_apps() ->
ejabberd:start_app(fast_tls),
ejabberd:start_app(xmpp),
ejabberd:start_app(cache_tab),
- start_eimp().
+ ejabberd:start_app(eimp).
setup_if_elixir_conf_used() ->
case ejabberd_config:is_using_elixir_config() of
@@ -174,11 +174,3 @@ start_elixir_application() ->
_ ->
ok
end.
-
--ifdef(GRAPHICS).
-start_eimp() ->
- ejabberd:start_app(eimp).
--else.
-start_eimp() ->
- ok.
--endif.
diff --git a/src/misc.erl b/src/misc.erl
index b7654cbea..9f3210d5e 100644
--- a/src/misc.erl
+++ b/src/misc.erl
@@ -33,7 +33,7 @@
atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
l2i/1, i2l/1, i2l/2, expr_to_term/1, term_to_expr/1,
now_to_usec/1, usec_to_now/1, encode_pid/1, decode_pid/2,
- compile_exprs/2, join_atoms/2, try_read_file/1, have_eimp/0,
+ compile_exprs/2, join_atoms/2, try_read_file/1,
css_dir/0, img_dir/0, js_dir/0, read_css/1, read_img/1, read_js/1]).
%% Deprecated functions
@@ -214,12 +214,6 @@ try_read_file(Path) ->
erlang:error(badarg)
end.
--ifdef(GRAPHICS).
-have_eimp() -> true.
--else.
-have_eimp() -> false.
--endif.
-
-spec css_dir() -> file:filename().
css_dir() ->
case os:getenv("EJABBERD_CSS_PATH") of
diff --git a/src/mod_avatar.erl b/src/mod_avatar.erl
index c11c68779..b72946df4 100644
--- a/src/mod_avatar.erl
+++ b/src/mod_avatar.erl
@@ -38,21 +38,12 @@
%%% API
%%%===================================================================
start(Host, _Opts) ->
- case misc:have_eimp() of
- true ->
- ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE,
- pubsub_publish_item, 50),
- ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
- vcard_iq_convert, 30),
- ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
- vcard_iq_publish, 100);
- false ->
- ?CRITICAL_MSG("ejabberd is built without "
- "graphics support: reconfigure it with "
- "--enable-graphics or disable '~s'",
- [?MODULE]),
- {error, graphics_not_compiled}
- end.
+ ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE,
+ pubsub_publish_item, 50),
+ ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
+ vcard_iq_convert, 30),
+ ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
+ vcard_iq_publish, 100).
stop(Host) ->
ejabberd_hooks:delete(pubsub_publish_item, Host, ?MODULE,
@@ -416,35 +407,21 @@ decode_mime_type(MimeType) ->
encode_mime_type(Type) ->
<<"image/", (atom_to_binary(Type, latin1))/binary>>.
-mod_opt_type({convert, png}) ->
- fun(jpeg) -> jpeg;
- (webp) -> webp;
- (gif) -> gif
- end;
-mod_opt_type({convert, webp}) ->
- fun(jpeg) -> jpeg;
- (png) -> png;
- (gif) -> gif
- end;
-mod_opt_type({convert, jpeg}) ->
- fun(png) -> png;
- (webp) -> webp;
- (gif) -> gif
- end;
-mod_opt_type({convert, gif}) ->
- fun(png) -> png;
- (jpeg) -> jpeg;
- (webp) -> webp
- end;
-mod_opt_type({convert, default}) ->
- fun(png) -> png;
- (webp) -> webp;
- (jpeg) -> jpeg;
- (gif) -> gif
+warn(Format) ->
+ ?WARNING_MSG("ejabberd is not compiled with ~p support", [Format]).
+
+mod_opt_type({convert, From}) when From == webp; From == jpeg;
+ From == png; From == gif ->
+ fun(To) when is_atom(To), To /= From ->
+ case eimp:is_supported(From) of
+ false ->
+ warn(From);
+ true ->
+ case eimp:is_supported(To) of
+ false -> warn(To);
+ true -> To
+ end
+ end
end;
mod_opt_type(_) ->
- [{convert, default},
- {convert, webp},
- {convert, png},
- {convert, gif},
- {convert, jpeg}].
+ [{convert, T} || T <- [default|eimp:supported_formats()]].
diff --git a/src/mod_http_upload.erl b/src/mod_http_upload.erl
index f7ff56b0b..df8362d4f 100644
--- a/src/mod_http_upload.erl
+++ b/src/mod_http_upload.erl
@@ -196,7 +196,19 @@ mod_opt_type(custom_headers) ->
mod_opt_type(rm_on_unregister) ->
fun(B) when is_boolean(B) -> B end;
mod_opt_type(thumbnail) ->
- fun(B) when is_boolean(B) -> B end;
+ fun(true) ->
+ case eimp:supported_formats() of
+ [] ->
+ ?WARNING_MSG("ejabberd is built without image converter "
+ "support, option '~s' is ignored",
+ [thumbnail]),
+ erlang:error(badarg);
+ _ ->
+ true
+ end;
+ (false) ->
+ false
+ end;
mod_opt_type(_) ->
[host, hosts, name, access, max_size, secret_length, jid_in_url, file_mode,
dir_mode, docroot, put_url, get_url, service_url, custom_headers,
@@ -237,20 +249,6 @@ init([ServerHost, Opts]) ->
Mode ->
file:change_mode(DocRoot2, Mode)
end,
- case Thumbnail of
- true ->
- case misc:have_eimp() of
- false ->
- ?ERROR_MSG("ejabberd is built without graphics support, "
- "please rebuild it with --enable-graphics or "
- "set 'thumbnail: false' for module '~s' in "
- "ejabberd.yml", [?MODULE]);
- _ ->
- ok
- end;
- false ->
- ok
- end,
lists:foreach(
fun(Host) ->
ejabberd_router:register_route(Host, ServerHost)
diff --git a/vars.config.in b/vars.config.in
index ff549242d..44dd40c1c 100644
--- a/vars.config.in
+++ b/vars.config.in
@@ -43,7 +43,6 @@
{iconv, @iconv@}.
{stun, @stun@}.
{sip, @sip@}.
-{graphics, @graphics@}.
%% Version
{vsn, "@PACKAGE_VERSION@"}.