# HG changeset patch # User Michel Le Bihan # Date 1487019053 -3600 # Node ID e6a3bdbce7b9c8a61645126195e25543d81b1005 # Parent 5ca2470a77552d21c1a4690a3d1509beeb5c3481 mod_pep_vcard_png_avatar: Move to dwebp, handle errors on opening file_png. diff -r 5ca2470a7755 -r e6a3bdbce7b9 mod_pep_vcard_png_avatar/README.markdown --- a/mod_pep_vcard_png_avatar/README.markdown Sun Feb 12 21:24:08 2017 +0100 +++ b/mod_pep_vcard_png_avatar/README.markdown Mon Feb 13 21:50:53 2017 +0100 @@ -3,7 +3,7 @@ Conversations (an XMPP client for Android) is publishing PEP avatars in the webp file format. However Pidgin and other XMPP desktop clients can only show vcard avatars, that are in the PNG file format. This module is the [mod_pep_vcard_avatar](https://modules.prosody.im/mod_pep_vcard_avatar.html) module extended to also change the avatar file format to PNG. -This module needs `convert` from ImageMagick as an additional dependency. +This module needs `dwebp` from `webp` package as an additional dependency. Configuration ============= diff -r 5ca2470a7755 -r e6a3bdbce7b9 mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua --- a/mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua Sun Feb 12 21:24:08 2017 +0100 +++ b/mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua Mon Feb 13 21:50:53 2017 +0100 @@ -118,10 +118,14 @@ local file_webp = io.open("/tmp/Prosody_temp_avatar.webp", "w"); file_webp:write(base64.decode(pep_photo:get_child_text("data", "urn:xmpp:avatar:data"))); file_webp:close(); - os.execute("convert /tmp/Prosody_temp_avatar.webp /tmp/Prosody_temp_avatar.png"); + os.execute("dwebp /tmp/Prosody_temp_avatar.webp -o /tmp/Prosody_temp_avatar.png"); local file_png = io.open("/tmp/Prosody_temp_avatar.png", "r"); - image=base64.encode(file_png:read("*a")); - file_png:close(); + if file_png ~= nil then + image=base64.encode(file_png:read("*a")); + file_png:close(); + else + module:log("error", "Couldn't access /tmp/Prosody_temp_avatar.png. Are you sure that /tmp is readable and writable and that Prosody can execute the dwebp command?"); + end os.remove("/tmp/Prosody_temp_avatar.webp"); os.remove("/tmp/Prosody_temp_avatar.png"); end