parent
37b1e38f02
commit
6350b5e4c7
@ -0,0 +1,42 @@
|
|||||||
|
package au.com.royalpay.payment.manage.valid;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
||||||
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
||||||
|
import cn.yixblog.platform.http.HttpRequestGenerator;
|
||||||
|
import cn.yixblog.platform.http.HttpRequestResult;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class ImageTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws IOException {
|
||||||
|
try (ByteArrayOutputStream ous = new ByteArrayOutputStream()){
|
||||||
|
HttpRequestResult boardBackgroundResult = new HttpRequestGenerator("https://au.rpaygroup.com/static/images/post.jpg",
|
||||||
|
RequestMethod.GET).execute();
|
||||||
|
if (boardBackgroundResult.isSuccess()) {
|
||||||
|
InputStream ins = boardBackgroundResult.getResponseContentStream();
|
||||||
|
BufferedImage background = ImageIO.read(ins);
|
||||||
|
IOUtils.closeQuietly(ins);
|
||||||
|
// Graphics g = background.getGraphics();
|
||||||
|
// drawPosterLogo(client, g);
|
||||||
|
// g.dispose();
|
||||||
|
|
||||||
|
ImageIO.write(background, "jpeg", ous);
|
||||||
|
ous.flush();
|
||||||
|
System.out.println(ous.toByteArray().length);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ServerErrorException("Error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue