Changeset

2496:e6a3bdbce7b9

mod_pep_vcard_png_avatar: Move to dwebp, handle errors on opening file_png.
author Michel Le Bihan <michel@lebihan.pl>
date Mon, 13 Feb 2017 21:50:53 +0100
parents 2495:5ca2470a7755
children 2497:c6761ebe613b
files mod_pep_vcard_png_avatar/README.markdown mod_pep_vcard_png_avatar/mod_pep_vcard_png_avatar.lua
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
 =============
--- 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