aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/NewMessage.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-21 13:54:35 +0300
committerGravatar Vitaly Takmazov2016-07-21 13:54:35 +0300
commit491f22135b985e1dfa8d2ff15ea38e59269659c1 (patch)
tree58164f5a1243c81650e64a5b42b4542965df3030 /juick-www/src/main/java/com/juick/www/NewMessage.java
parentc19397fb6d4635120a1a8cdaef6d66f0b36e3c4b (diff)
www: Thumbnailator for comments
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/NewMessage.java')
-rw-r--r--juick-www/src/main/java/com/juick/www/NewMessage.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/juick-www/src/main/java/com/juick/www/NewMessage.java b/juick-www/src/main/java/com/juick/www/NewMessage.java
index bb169b60..63cfe3ed 100644
--- a/juick-www/src/main/java/com/juick/www/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/NewMessage.java
@@ -26,6 +26,7 @@ import com.juick.xmpp.extensions.JuickMessage;
import com.juick.xmpp.extensions.JuickUser;
import com.juick.xmpp.extensions.Nickname;
import com.juick.xmpp.extensions.XOOB;
+import net.coobird.thumbnailator.Thumbnails;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.servlet.ServletException;
@@ -36,6 +37,9 @@ import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
+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.logging.Level;
@@ -49,6 +53,13 @@ public class NewMessage {
private static final Logger logger = Logger.getLogger(NewMessage.class.getName());
+ private String tmpDir, imgDir;
+
+ public NewMessage(String tmpDir, String imgDir) {
+ this.tmpDir = tmpDir;
+ this.imgDir = imgDir;
+ }
+
protected void doGetNewMessage(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException {
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
@@ -361,7 +372,14 @@ public class NewMessage {
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, attachmentType), 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();