data:image下载到本地

  • Post author:
  • Post category:其他



String s = “data:image/gif;base64,R0lGODlheAAoAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYmIiI6LipKNjZaQj5mSkZ6VkaOXkaaZkqmakqubk62ck66dlLCdlLCelbGelbKelrKflrKflrKflrOflbOflbOflLOfk7SfkbSfj7SfjbWei7WeiLaehbeegreefrieermedrqecbuebMCaaMeWZM6SYNOPYdiMYt2JY+GGZOWEZOiCZeyAZvCEZPSJY/eNYvmSYPuWX/yaXv2eXf2hXP6kW/6mW/utZPmzbve4dvS8f/K/hvDDj+/Hlu7KnuzOpevRq+vUsOrWtOrYuOrZvOrbv+zhyu/m1PHr3vTu4/bx6Pf07fn28fr49Pv69/z7+f38+/79/f7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7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RAhiinq4KW8gabhLaR1iXgEjrpDoz3ZbVjZSJ6LgNcQUZEjHC1C0wQTUgxOUMs+mPBEMFToG94phRziSBCS0FNEIO3tIOIQRij0dwtwkJFTAiGHFKOht6Px7o0HYQ+atqFBhPSiE7ywIx4rEo4gCSw2xrvjQsohyUVa8pKYzKQmN8nJTnryk6AMpUACAgA7”;


// 或者使用


String[] split = s.split(“,”);


byte[] encode2 = Base64Utils.

decode

(split[1].getBytes());


FileUtil.

writeBytes

(encode2, “D:\\cycloud\\uploadPath\\ValidCodeImg.png”);


InputStream inStream = new FileInputStream(“D:\\cycloud\\uploadPath\\ValidCodeImg.gif”);


ImageReaderSpi readerSpi = new GIFImageReaderSpi();


GIFImageReader gifReader = (GIFImageReader) readerSpi.createReaderInstance();


//这个地方需要把InputStream转一下ImageInputStream


gifReader.setInput(ImageIO.

createImageInputStream

(inStream));


//获取总帧数


int num = gifReader.getNumImages(true);



log

.info(“gif帧数:” + num);


File newfile = new File(“D:\\cycloud\\uploadPath\\ValidCodeImg.png”);


ImageWriterSpi writerSpi = new GIFImageWriterSpi();


GIFImageWriter writer = (GIFImageWriter) writerSpi.createWriterInstance();


ImageOutputStream out = new FileImageOutputStream(newfile);


writer.setOutput(out);


// 读取最后一帧的图片 也就是gif显示完全的那一帧


BufferedImage read = gifReader.read(num-4);


writer.write(read);



版权声明:本文为m0_54019942原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。