aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src/main/java/com/juick/service/ImagesServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-common/src/main/java/com/juick/service/ImagesServiceImpl.java')
-rw-r--r--juick-common/src/main/java/com/juick/service/ImagesServiceImpl.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/juick-common/src/main/java/com/juick/service/ImagesServiceImpl.java b/juick-common/src/main/java/com/juick/service/ImagesServiceImpl.java
index 3a5c77dd..dbc3f3a9 100644
--- a/juick-common/src/main/java/com/juick/service/ImagesServiceImpl.java
+++ b/juick-common/src/main/java/com/juick/service/ImagesServiceImpl.java
@@ -7,9 +7,14 @@ import com.juick.server.util.ImageUtils;
import org.springframework.util.StringUtils;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
public class ImagesServiceImpl implements ImagesService {
+ private ImageUtils imageUtils;
+ public ImagesServiceImpl(String imgDir, String tmpDir) {
+ imageUtils = new ImageUtils(imgDir, tmpDir);
+ }
@Override
public void setAttachmentMetadata(String imgDir, String baseUrl, Message msg) throws Exception {
if (!StringUtils.isEmpty(msg.getAttachmentType())) {
@@ -42,30 +47,32 @@ public class ImagesServiceImpl implements ImagesService {
builder.append(".").append(msg.getAttachmentType());
String originalUrl = builder.toString();
- Attachment original = new Attachment();
+ Attachment original = imageUtils.getAttachment(fullImage);
original.setUrl(originalUrl);
- original.setHeight(ImageUtils.getImageHeight(fullImage));
- original.setWidth(ImageUtils.getImageWidth(fullImage));
- Attachment medium = new Attachment();
+ Attachment medium = imageUtils.getAttachment(mediumImage);
medium.setUrl(photo.getMedium());
- medium.setWidth(ImageUtils.getImageWidth(mediumImage));
- medium.setHeight(ImageUtils.getImageHeight(mediumImage));
original.setMedium(medium);
- Attachment small = new Attachment();
+ Attachment small = imageUtils.getAttachment(smallImage);
small.setUrl(photo.getSmall());
- small.setWidth(ImageUtils.getImageWidth(smallImage));
- small.setHeight(ImageUtils.getImageHeight(smallImage));
original.setSmall(small);
- Attachment thumb = new Attachment();
+ Attachment thumb = imageUtils.getAttachment(thumbnailImage);
thumb.setUrl(photo.getMedium());
- thumb.setWidth(ImageUtils.getImageWidth(thumbnailImage));
- thumb.setHeight(ImageUtils.getImageHeight(thumbnailImage));
original.setThumbnail(thumb);
msg.setAttachment(original);
}
}
+
+ @Override
+ public void saveImageWithPreviews(String tempFilename, String outputFilename) throws IOException {
+ imageUtils.saveImageWithPreviews(tempFilename, outputFilename);
+ }
+
+ @Override
+ public void saveAvatar(String tempFilename, int uid) throws IOException {
+ imageUtils.saveAvatar(tempFilename, uid);
+ }
}