aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-api/src/main/java/com')
-rw-r--r--juick-api/src/main/java/com/juick/api/Main.java27
1 files changed, 24 insertions, 3 deletions
diff --git a/juick-api/src/main/java/com/juick/api/Main.java b/juick-api/src/main/java/com/juick/api/Main.java
index 676aab79..47c4e448 100644
--- a/juick-api/src/main/java/com/juick/api/Main.java
+++ b/juick-api/src/main/java/com/juick/api/Main.java
@@ -30,6 +30,7 @@ import com.juick.xmpp.StreamComponent;
import com.juick.xmpp.extensions.JuickMessage;
import com.juick.xmpp.extensions.Nickname;
import com.juick.xmpp.extensions.XOOB;
+import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -44,6 +45,9 @@ import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.net.Socket;
import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -68,6 +72,8 @@ public class Main extends HttpServlet implements Stream.StreamListener {
TelegramBotHook tgb;
SkypeEndpoint sep;
+ String tmpDir, imgDir;
+
@Override
public void init() throws ServletException {
super.init();
@@ -87,7 +93,8 @@ public class Main extends HttpServlet implements Stream.StreamListener {
sep = new SkypeEndpoint();
setupXmppComponent(conf.getProperty("xmpp_host", "localhost"), Integer.parseInt(conf.getProperty("xmpp_port", "5347")),
conf.getProperty("xmpp_jid", "api.localhost"), conf.getProperty("xmpp_password"));
-
+ tmpDir = conf.getProperty("upload_tmp_dir", "/var/www/juick.com/i/tmp/");
+ imgDir = conf.getProperty("img_path", "/var/www/juick.com/i/");
} catch (IOException e) {
log("API initialization error", e);
}
@@ -301,7 +308,14 @@ public class Main extends HttpServlet implements Stream.StreamListener {
String fname = mid + "." + attachmentType;
String attachmentURL = "http://i.juick.com/photos-1024/" + fname;
- Runtime.getRuntime().exec("/var/www/juick.com/cgi/p-convert.sh /var/www/juick.com/i/tmp/" + attachmentFName + " " + fname);
+ Path origName = Paths.get(imgDir, "p", fname);
+ Files.move(Paths.get(tmpDir, attachmentFName), origName);
+ Thumbnails.of(origName.toFile()).size(1024, 1024).outputQuality(0.9)
+ .toFile(Paths.get(imgDir, "photos-1024", fname).toFile());
+ Thumbnails.of(origName.toFile()).size(512, 512).outputQuality(0.9)
+ .toFile(Paths.get(imgDir, "photos-512", fname).toFile());
+ Thumbnails.of(origName.toFile()).size(160, 120).outputQuality(0.9)
+ .toFile(Paths.get(imgDir, "ps", fname).toFile());
body = attachmentURL + "\n" + body;
XOOB xoob = new XOOB();
@@ -422,7 +436,14 @@ public class Main extends HttpServlet implements Stream.StreamListener {
String fname = mid + "-" + ridnew + "." + attachmentType;
String attachmentURL = "http://i.juick.com/photos-1024/" + fname;
- Runtime.getRuntime().exec("/var/www/juick.com/cgi/p-convert.sh /var/www/juick.com/i/tmp/" + attachmentFName + " " + fname);
+ Path origName = Paths.get(imgDir, "p", fname);
+ Files.move(Paths.get(tmpDir, attachmentFName), origName);
+ Thumbnails.of(origName.toFile()).size(1024, 1024).outputQuality(0.9)
+ .toFile(Paths.get(imgDir, "photos-1024", fname).toFile());
+ Thumbnails.of(origName.toFile()).size(512, 512).outputQuality(0.9)
+ .toFile(Paths.get(imgDir, "photos-512", fname).toFile());
+ Thumbnails.of(origName.toFile()).size(160, 120).outputQuality(0.9)
+ .toFile(Paths.get(imgDir, "ps", fname).toFile());
body = attachmentURL + "\n" + body;
XOOB xoob = new XOOB();