Created
July 8, 2018 03:12
-
-
Save xcuYao/6ffa39fd06747360bbe3dea04a4c43e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Image 转 Base64 | |
BufferedImage image = AliyunUtils.readImgFromOSS("jindi-api-data","api/6fd514de0e0983c8ffc451a200056001.png"); | |
<!--BufferedImage image = ImageIO.read(new File(""));--> | |
ByteArrayOutputStream output = new ByteArrayOutputStream(); | |
ImageIO.write(image, "png", output); | |
String base64 = Base64.getEncoder().encodeToString(output.toByteArray()); | |
//base64 转 Image | |
byte[] imageData = Base64.getDecoder().decode(base64.getBytes()); | |
BufferedImage image2 = ImageIO.read(new ByteArrayInputStream(imageData)); | |
ImageIO.write(image2, "png", new File("/Users/yaoning/Desktop/a.png")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment