Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
netbuffer committed Apr 3, 2018
2 parents e15b36d 6e4aed6 commit 453ff59
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 55 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 24,7 @@
* itextpdf

> ## github:[https://github.com/netbuffer/ssmbootstrap_table](https://github.com/netbuffer/ssmbootstrap_table)
> ## git@osc:[https://git.oschina.net/gradle/ssmbootstrap_table](https://git.oschina.net/gradle/ssmbootstrap_table)
> ## git@osc:[https://gitee.com/netbuffer/ssmbootstrap_table](https://gitee.com/netbuffer/ssmbootstrap_table)
## How to run
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
Expand Down Expand Up @@ -54,14 54,14 @@ metrics | @Timed
> * swagger (test `swagger` api doc)
# other projects
> `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)
> `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)
> `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)
> `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)
> `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)
> `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)
> `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)
> `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)
> `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)
> `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)
> `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)
> `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)
106 changes: 58 additions & 48 deletions src/test/java/cn/com/ttblog/ssmbootstrap_table/TestThumbnailator.java
Original file line number Diff line number Diff line change
@@ -1,63 1,73 @@
package cn.com.ttblog.ssmbootstrap_table;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Coordinate;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Positions;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;

/**
* http://rensanning.iteye.com/blog/1545708
* Thumbnailator 图片裁切、缩放、水印等
*/
public class TestThumbnailator {

private static final String FILENAME="thumbnailator.jpg";
private static final Logger LOG=LoggerFactory.getLogger(TestThumbnailator.class);
@Test
public void testThumbnailator() throws IOException{

private static final String FILENAME = "thumbnailator.jpg";
private static final Logger LOG = LoggerFactory.getLogger(TestThumbnailator.class);

@Test
public void testThumbnailator() throws IOException {
// 指定大小进行缩放
/*
* 若图片横比200小,高比300小,不变
* 若图片横比200小,高比300大,高缩小到300,图片比例不变
* 若图片横比200大,高比300小,横缩小到200,图片比例不变
* 若图片横比200大,高比300大,图片按比例缩小,横为200或高为300
*/
String file=this.getClass().getResource(FILENAME).getFile();
File f=new File(file);
LOG.debug("file-path:{},parent:{}",f.getAbsolutePath(),f.getParent());
Thumbnails.of(f.getAbsolutePath())
.size(200, 300)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");

Thumbnails.of(f.getAbsolutePath())
.size(2560, 2048)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");

Thumbnails.of(f.getAbsolutePath())
.scale(0.25f)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");

Thumbnails.of(f.getAbsolutePath())
.scale(1.10f)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");
}

@Test
public void testWaterMark() throws IOException{
String file=this.getClass().getResource("qr.jpg").getFile(),icon=this.getClass().getResource("java.png").getFile();
File f=new File(file);
Thumbnails.of(f.getAbsolutePath())
.size(200, 200)
.watermark(Positions.CENTER, ImageIO.read(new File(icon)), 0.8f)
.outputQuality(0.8f)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");
}
/*
* 若图片横比200小,高比300小,不变
* 若图片横比200小,高比300大,高缩小到300,图片比例不变
* 若图片横比200大,高比300小,横缩小到200,图片比例不变
* 若图片横比200大,高比300大,图片按比例缩小,横为200或高为300
*/
String file = this.getClass().getResource(FILENAME).getFile();
File f = new File(file);
LOG.debug("file-path:{},parent:{}", f.getAbsolutePath(), f.getParent());
Thumbnails.of(f.getAbsolutePath())
.size(200, 300)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");

Thumbnails.of(f.getAbsolutePath())
.size(2560, 2048)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");

Thumbnails.of(f.getAbsolutePath())
.scale(0.25f)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");

Thumbnails.of(f.getAbsolutePath())
.scale(1.10f)
.toFile("thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");
}

@Test
public void testWaterMark() throws IOException {
String file = "F:\\image\\bg.png",
icon = "F:\\image\\showqrcode.jpg";
BufferedImage image = ImageIO.read(new File(file));
Thumbnails.of(image)
.size(image.getWidth(), image.getHeight())
.watermark(new Coordinate(229, 178), Thumbnails.of(icon).size(240, 240).asBufferedImage(), 1.0f)
.outputQuality(1.0f)
.toFile("f:/image/thumbnailator" RandomStringUtils.randomAlphabetic(5) ".jpg");
}

@Test
public void testImageIO() throws IOException {
URL url = new URL("https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEC8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyYXpCdElNd3dlYm0xSzgxbzFxY0oAAgRcwJhaAwQsAQAA");
BufferedImage bufferedImage = ImageIO.read(url);
LOG.info("bufferedImage:{}", bufferedImage);
ImageIO.write(bufferedImage, "jpg", new File("f:/image/qr.jpg"));
}
}

0 comments on commit 453ff59

Please sign in to comment.