|
@ -1,6 +1,5 @@
|
1
|
1
|
package com.ekexiu.portal.service;
|
2
|
2
|
|
3
|
|
import java.awt.Image;
|
4
|
3
|
import java.awt.image.BufferedImage;
|
5
|
4
|
import java.io.ByteArrayInputStream;
|
6
|
5
|
import java.io.ByteArrayOutputStream;
|
|
@ -14,7 +13,6 @@ import java.util.concurrent.TimeUnit;
|
14
|
13
|
|
15
|
14
|
import javax.imageio.ImageIO;
|
16
|
15
|
|
17
|
|
import org.jfw.apt.annotation.Nullable;
|
18
|
16
|
import org.jfw.apt.web.annotation.Path;
|
19
|
17
|
import org.jfw.apt.web.annotation.operate.Get;
|
20
|
18
|
import org.jfw.apt.web.annotation.operate.Post;
|
|
@ -319,30 +317,25 @@ public class ImageService {
|
319
|
317
|
|
320
|
318
|
@Post
|
321
|
319
|
@Path("/saveHead")
|
322
|
|
public boolean saveImage(String id, String base64) throws IOException {
|
|
320
|
public boolean saveImage(String id, String base64, Integer angle) throws IOException {
|
323
|
321
|
Base64 bs64 = new Base64();
|
324
|
322
|
byte[] bs = bs64.decode(base64.getBytes("UTF-8"));
|
325
|
|
byte[] li = this.zoomImage(bs, this.largeHeadPhotoWidth, this.largeHeadPhotoHeight);
|
326
|
|
byte[] mi = this.zoomImage(bs, this.middleHeadPhotoWidth, this.middleHeadPhotoHeight);
|
327
|
|
byte[] si = this.zoomImage(bs, this.smallHeadPhotoWidth, this.smallHeadPhotoHeight);
|
328
|
|
IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_s.jpg")), si, true);
|
329
|
|
IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_m.jpg")), mi, true);
|
330
|
|
IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_l.jpg")), li, true);
|
331
|
|
return true;
|
332
|
|
}
|
333
|
|
@Post
|
334
|
|
@Path("/test")
|
335
|
|
public boolean Image(String id, String base64, @Nullable Integer angle) throws IOException {
|
336
|
|
Base64 bs64 = new Base64();
|
337
|
|
byte[] bs = bs64.decode(base64.getBytes("UTF-8"));
|
338
|
|
Image image = PictureRotating.bytesToImage(bs);
|
339
|
|
BufferedImage des = PictureRotating.Rotate(image, angle);
|
340
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
341
|
|
boolean flag = ImageIO.write(des, "jpg", out);
|
342
|
|
byte[] bytes = out.toByteArray();
|
343
|
|
byte[] li = this.zoomImage(bytes, this.largeHeadPhotoWidth, this.largeHeadPhotoHeight);
|
344
|
|
byte[] mi = this.zoomImage(bytes, this.middleHeadPhotoWidth, this.middleHeadPhotoHeight);
|
345
|
|
byte[] si = this.zoomImage(bytes, this.smallHeadPhotoWidth, this.smallHeadPhotoHeight);
|
|
323
|
byte[] li,mi,si;
|
|
324
|
if(0 == angle){
|
|
325
|
li = this.zoomImage(bs, this.largeHeadPhotoWidth, this.largeHeadPhotoHeight);
|
|
326
|
mi = this.zoomImage(bs, this.middleHeadPhotoWidth, this.middleHeadPhotoHeight);
|
|
327
|
si = this.zoomImage(bs, this.smallHeadPhotoWidth, this.smallHeadPhotoHeight);
|
|
328
|
}else{
|
|
329
|
java.awt.Image image = PictureRotating.bytesToImage(bs);
|
|
330
|
BufferedImage des = PictureRotating.Rotate(image, angle);
|
|
331
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
332
|
@SuppressWarnings("unused")
|
|
333
|
boolean flag = ImageIO.write(des, "jpg", out);
|
|
334
|
byte[] bytes = out.toByteArray();
|
|
335
|
li = this.zoomImage(bytes, this.largeHeadPhotoWidth, this.largeHeadPhotoHeight);
|
|
336
|
mi = this.zoomImage(bytes, this.middleHeadPhotoWidth, this.middleHeadPhotoHeight);
|
|
337
|
si = this.zoomImage(bytes, this.smallHeadPhotoWidth, this.smallHeadPhotoHeight);
|
|
338
|
}
|
346
|
339
|
IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_s.jpg")), si, true);
|
347
|
340
|
IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_m.jpg")), mi, true);
|
348
|
341
|
IoUtil.saveStream(new FileOutputStream(new File(this.headPath, id + "_l.jpg")), li, true);
|