diff options
author | 2017-03-20 10:32:04 +0300 | |
---|---|---|
committer | 2017-03-20 10:32:04 +0300 | |
commit | 3c5ec95b59dac6820751a9e3d498cf7bf3538724 (patch) | |
tree | a04e34b01a629fa8fa3d5309b3a0b7898e546c95 /juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java | |
parent | 5889ba6af9f5c3cb0391bec8fbbcad0165519738 (diff) |
Thumbnailator -> imgscalr
Diffstat (limited to 'juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java')
-rw-r--r-- | juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java index d1c872d7..58668dc1 100644 --- a/juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java +++ b/juick-spring-www/src/main/java/com/juick/www/controllers/SettingsController.java @@ -8,9 +8,9 @@ import com.juick.server.util.HttpForbiddenException; import com.juick.server.util.HttpUtils; import com.juick.service.*; import com.juick.util.UserUtils; -import net.coobird.thumbnailator.Thumbnails; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; +import org.imgscalr.Scalr; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; @@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; +import javax.imageio.ImageIO; import javax.inject.Inject; import javax.mail.Message; import javax.mail.MessagingException; @@ -31,6 +32,7 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -162,8 +164,9 @@ public class SettingsController { Path a = Paths.get(imgPath, "a", targetName); Path as = Paths.get(imgPath, "as", targetName); Files.move(Paths.get(tmpDir, avatarTmpPath), ao, StandardCopyOption.REPLACE_EXISTING); - Thumbnails.of(ao.toFile()).size(96, 96).toFile(a.toFile()); - Thumbnails.of(ao.toFile()).size(32, 32).toFile(as.toFile()); + BufferedImage originalImage = ImageIO.read(ao.toFile()); + ImageIO.write(Scalr.resize(originalImage, 96), "png", a.toFile()); + ImageIO.write(Scalr.resize(originalImage, 32), "png", as.toFile()); } if (userService.updateUserInfo(visitor, info)) { result = String.format("<p>Your info is updated.</p><p><a href='/%s/'>Back to blog</a>.</p>", visitor.getName()); |