Skip to content

Commit f4fd4a9

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents ea60c13 + 7d9b648 commit f4fd4a9

File tree

2 files changed

+65
-55
lines changed

2 files changed

+65
-55
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* itextpdf
2525

2626
> ## github:[https://github.com/netbuffer/ssmbootstrap_table](https://github.com/netbuffer/ssmbootstrap_table)
27-
> ## git@osc:[https://git.oschina.net/gradle/ssmbootstrap_table](https://git.oschina.net/gradle/ssmbootstrap_table)
27+
> ## git@osc:[https://gitee.com/netbuffer/ssmbootstrap_table](https://gitee.com/netbuffer/ssmbootstrap_table)
2828
2929
## How to run
3030
The project constructed by `maven`, please execute under the `src/main/java` `SQL script` to your `MySQL` database operation, and then modify the database configuration information `jdbc.properties` under the path `src/main/resource` configuration file in the project directory, enter, execute `mvn tomcat7:run` to run
@@ -54,14 +54,14 @@ metrics | @Timed
5454
> * swagger (test `swagger` api doc)
5555
5656
# other projects
57-
> `ssmbt(ssmbootstrap_table maven module )` github:[https://github.com/netbuffer/ssmbt](https://github.com/netbuffer/ssmbt)`/`git@osc:[https://git.oschina.net/netbuffer/ssmbt](https://git.oschina.net/netbuffer/ssmbt)
57+
> `ssmbt(ssmbootstrap_table maven module )` github:[https://github.com/netbuffer/ssmbt](https://github.com/netbuffer/ssmbt)`/`git@osc:[https://gitee.com/netbuffer/ssmbt](https://gitee.com/netbuffer/ssmbt)
5858
59-
> `sssbootstrap_table(spring+springmvc+spring data jpa)` github:[https://github.com/netbuffer/sssbootstrap_table](https://github.com/netbuffer/sssbootstrap_table)`/`git@osc:[https://git.oschina.net/netbuffer/sssbootstrap_table](https://git.oschina.net/netbuffer/sssbootstrap_table)
59+
> `sssbootstrap_table(spring+springmvc+spring data jpa)` github:[https://github.com/netbuffer/sssbootstrap_table](https://github.com/netbuffer/sssbootstrap_table)`/`git@osc:[https://gitee.com/netbuffer/sssbootstrap_table](https://gitee.com/netbuffer/sssbootstrap_table)
6060
61-
> `sshbootstrap_table(spring+struts2+hibernate)` github:[https://github.com/netbuffer/sshbootstrap-table](https://github.com/netbuffer/sshbootstrap-table)`/`git@osc:[https://git.oschina.net/netbuffer/sshbootstrap-table](https://git.oschina.net/netbuffer/sshbootstrap-table)
61+
> `sshbootstrap_table(spring+struts2+hibernate)` github:[https://github.com/netbuffer/sshbootstrap-table](https://github.com/netbuffer/sshbootstrap-table)`/`git@osc:[https://gitee.com/netbuffer/sshbootstrap-table](https://gitee.com/netbuffer/sshbootstrap-table)
6262
63-
> `spring-boot-bootstrap_table(springboot)` github:[https://github.com/netbuffer/spring-boot-bootstrap_table](https://github.com/netbuffer/spring-boot-bootstrap_table)`/`git@osc:[https://git.oschina.net/netbuffer/spring-boot-bootstrap_table](https://git.oschina.net/netbuffer/spring-boot-bootstrap_table)
63+
> `spring-boot-bootstrap_table(springboot)` github:[https://github.com/netbuffer/spring-boot-bootstrap_table](https://github.com/netbuffer/spring-boot-bootstrap_table)`/`git@osc:[https://gitee.com/netbuffer/spring-boot-bootstrap_table](https://gitee.com/netbuffer/spring-boot-bootstrap_table)
6464
65-
> `jfinal-bootstrap-table(jfinal)`github:[https://github.com/netbuffer/jfinal-bootstrap-table](https://github.com/netbuffer/jfinal-bootstrap-table)`/`git@osc:[http://git.oschina.net/gradle/jfinal-bootstrap-table](http://git.oschina.net/gradle/jfinal-bootstrap-table)
65+
> `jfinal-bootstrap-table(jfinal)`github:[https://github.com/netbuffer/jfinal-bootstrap-table](https://github.com/netbuffer/jfinal-bootstrap-table)`/`git@osc:[http://gitee.com/netbuffer/jfinal-bootstrap-table](http://gitee.com/netbuffer/jfinal-bootstrap-table)
6666
67-
> `medoo_bootstrap_table(php5)`github:[https://github.com/netbuffer/medoo_bootstrap_table](https://github.com/netbuffer/medoo_bootstrap_table)`/`git@osc:[http://git.oschina.net/gradle/medoo_bootstrap_table](http://git.oschina.net/gradle/medoo_bootstrap_table)
67+
> `medoo_bootstrap_table(php5)`github:[https://github.com/netbuffer/medoo_bootstrap_table](https://github.com/netbuffer/medoo_bootstrap_table)`/`git@osc:[http://gitee.com/netbuffer/medoo_bootstrap_table](http://gitee.com/netbuffer/medoo_bootstrap_table)
Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,73 @@
11
package cn.com.ttblog.ssmbootstrap_table;
22

3-
import java.io.File;
4-
import java.io.IOException;
5-
6-
import javax.imageio.ImageIO;
7-
3+
import net.coobird.thumbnailator.Thumbnails;
4+
import net.coobird.thumbnailator.geometry.Coordinate;
85
import org.apache.commons.lang3.RandomStringUtils;
96
import org.junit.Test;
107
import org.slf4j.Logger;
118
import org.slf4j.LoggerFactory;
129

13-
import net.coobird.thumbnailator.Thumbnails;
14-
import net.coobird.thumbnailator.geometry.Positions;
10+
import javax.imageio.ImageIO;
11+
import java.awt.image.BufferedImage;
12+
import java.io.File;
13+
import java.io.IOException;
14+
import java.net.URL;
1515

1616
/**
1717
* http://rensanning.iteye.com/blog/1545708
1818
* Thumbnailator 图片裁切、缩放、水印等
1919
*/
2020
public class TestThumbnailator {
21-
22-
private static final String FILENAME="thumbnailator.jpg";
23-
private static final Logger LOG=LoggerFactory.getLogger(TestThumbnailator.class);
24-
@Test
25-
public void testThumbnailator() throws IOException{
21+
22+
private static final String FILENAME = "thumbnailator.jpg";
23+
private static final Logger LOG = LoggerFactory.getLogger(TestThumbnailator.class);
24+
25+
@Test
26+
public void testThumbnailator() throws IOException {
2627
// 指定大小进行缩放
27-
/*
28-
* 若图片横比200小,高比300小,不变
29-
* 若图片横比200小,高比300大,高缩小到300,图片比例不变
30-
* 若图片横比200大,高比300小,横缩小到200,图片比例不变
31-
* 若图片横比200大,高比300大,图片按比例缩小,横为200或高为300
32-
*/
33-
String file=this.getClass().getResource(FILENAME).getFile();
34-
File f=new File(file);
35-
LOG.debug("file-path:{},parent:{}",f.getAbsolutePath(),f.getParent());
36-
Thumbnails.of(f.getAbsolutePath())
37-
.size(200, 300)
38-
.toFile("thumbnailator"+RandomStringUtils.randomAlphabetic(5)+".jpg");
39-
40-
Thumbnails.of(f.getAbsolutePath())
41-
.size(2560, 2048)
42-
.toFile("thumbnailator"+RandomStringUtils.randomAlphabetic(5)+".jpg");
43-
44-
Thumbnails.of(f.getAbsolutePath())
45-
.scale(0.25f)
46-
.toFile("thumbnailator"+RandomStringUtils.randomAlphabetic(5)+".jpg");
47-
48-
Thumbnails.of(f.getAbsolutePath())
49-
.scale(1.10f)
50-
.toFile("thumbnailator"+RandomStringUtils.randomAlphabetic(5)+".jpg");
51-
}
52-
53-
@Test
54-
public void testWaterMark() throws IOException{
55-
String file=this.getClass().getResource("qr.jpg").getFile(),icon=this.getClass().getResource("java.png").getFile();
56-
File f=new File(file);
57-
Thumbnails.of(f.getAbsolutePath())
58-
.size(200, 200)
59-
.watermark(Positions.CENTER, ImageIO.read(new File(icon)), 0.8f)
60-
.outputQuality(0.8f)
61-
.toFile("thumbnailator"+RandomStringUtils.randomAlphabetic(5)+".jpg");
62-
}
28+
/*
29+
* 若图片横比200小,高比300小,不变
30+
* 若图片横比200小,高比300大,高缩小到300,图片比例不变
31+
* 若图片横比200大,高比300小,横缩小到200,图片比例不变
32+
* 若图片横比200大,高比300大,图片按比例缩小,横为200或高为300
33+
*/
34+
String file = this.getClass().getResource(FILENAME).getFile();
35+
File f = new File(file);
36+
LOG.debug("file-path:{},parent:{}", f.getAbsolutePath(), f.getParent());
37+
Thumbnails.of(f.getAbsolutePath())
38+
.size(200, 300)
39+
.toFile("thumbnailator" + RandomStringUtils.randomAlphabetic(5) + ".jpg");
40+
41+
Thumbnails.of(f.getAbsolutePath())
42+
.size(2560, 2048)
43+
.toFile("thumbnailator" + RandomStringUtils.randomAlphabetic(5) + ".jpg");
44+
45+
Thumbnails.of(f.getAbsolutePath())
46+
.scale(0.25f)
47+
.toFile("thumbnailator" + RandomStringUtils.randomAlphabetic(5) + ".jpg");
48+
49+
Thumbnails.of(f.getAbsolutePath())
50+
.scale(1.10f)
51+
.toFile("thumbnailator" + RandomStringUtils.randomAlphabetic(5) + ".jpg");
52+
}
53+
54+
@Test
55+
public void testWaterMark() throws IOException {
56+
String file = "F:\\image\\bg.png",
57+
icon = "F:\\image\\showqrcode.jpg";
58+
BufferedImage image = ImageIO.read(new File(file));
59+
Thumbnails.of(image)
60+
.size(image.getWidth(), image.getHeight())
61+
.watermark(new Coordinate(229, 178), Thumbnails.of(icon).size(240, 240).asBufferedImage(), 1.0f)
62+
.outputQuality(1.0f)
63+
.toFile("f:/image/thumbnailator" + RandomStringUtils.randomAlphabetic(5) + ".jpg");
64+
}
65+
66+
@Test
67+
public void testImageIO() throws IOException {
68+
URL url = new URL("https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEC8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyYXpCdElNd3dlYm0xSzgxbzFxY0oAAgRcwJhaAwQsAQAA");
69+
BufferedImage bufferedImage = ImageIO.read(url);
70+
LOG.info("bufferedImage:{}", bufferedImage);
71+
ImageIO.write(bufferedImage, "jpg", new File("f:/image/qr.jpg"));
72+
}
6373
}

0 commit comments

Comments
 (0)