在最近的开发中,遇到了图片拼接、合成与Base64编码转换的问题,现在进行总结
图片拼接
1 | /** |
合成
1 | /** |
Base64
一张图片
转换成 Base64 之后,得到
1 | data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAAQABAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCABLAEsDASIAAhEBAxEB/8QAHQAAAgICAwEAAAAAAAAAAAAABwgABgMFAQIECf/EAEUQAAEDAwIDAwcKAwQLAAAAAAECAwQFBhEABxIhMQgTQRciN1FWYYEUFTJCcpSVtNLTcZGzFlJ1oSM0Q2NkZXOjsdHw/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AC52ld8EbcoboFAaYl3HJa70l3zmobZyAtQH0lHBwn3ZPLAKlVfdjcuqy1Spd813jUSeFmUWUD+CW8Afy1N9ajIqm8l3S5Kypfzq8ynJzhDZ7tI+CUjVL8QB1JwB6zoLR5RdwPbi5PxN39WuPKLuB7cXJ+Ju/q1X5cOXDUhEyJIjKWkLQl5pTZUn+8AoDI5HnrBoLR5RdwPbi5PxN39Wp5RdwPbi5PxN39WqvqDQWjyi7ge3Fyfibv6tco3H3BQoKTfNyBSTkH5zd/8AeqsOfIc9ZpsSXBf7ibFkRXsZ7t9pTav5KAOgP+y3aVuSjVaPTb8mKrFGdUEKmLQPlMXJ+mSkDvEjxBHFjmCehc9h5p9lt9lxDjTiQtC0nIUkjIIPiCNfKvx0/wB2aK/Ik7F2sqUFPONxlscZVzKW3Vtp/klIGgSndv0rXZ/jUv8Aqq0e9pYtC2m7PCt2ZVJi1K4qkrEDv057sKWUNIB+qPNK1EcyOWeQ0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O0q5e1zRrft+Ip+W8ocSsHgYRnm44fqpH+fQZJ19IbGt2JaVn0q2oB4o9OioYSojBWQOaj7ycn46lpWpbdpQDT7aosKlxzgqTHaCSs+tR6qPvJOt1oP//Z |
1 | /** |
使用
1 | String base64 = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAAQABAAD/2wBDAAUDBAQEAwU..."; |
使用开源库
关于图片处理,有一些开源库
- 阿里巴巴的 SimpleImage
- Google的 thumbnailator