简体   繁体   English

使用 JPEG Lossless 压缩图像并将图像转换为 Base64Encoded String

[英]Compress image using JPEG Lossless and convert the image to Base64Encoded String

We have a requirement to compress an image which will be of size around 50 KB - 75 KB within 25KB limit.我们需要压缩大小在 50 KB 到 75 KB 左右的图像,限制在 25 KB 以内。 We were following the example given in http://examples.javacodegeeks.com/desktop-java/imageio/compress-a-jpeg-file/ .我们遵循http://examples.javacodegeeks.com/desktop-java/imageio/compress-a-jpeg-file/ 中给出的示例。 by specifying the quality as 0.1f we are able to reduce the size of the image below 25 KB.通过将质量指定为 0.1f,我们能够将图像的大小减小到 25 KB 以下。 But the image looses its quality.但图像失去了它的质量。

We need your suggestion on:我们需要您的建议:

  1. How we can compress the image to be within 25 KB without any loss on the quality?我们如何将图像压缩到 25 KB 以内而不会降低质量?
  2. After compressing we are converting the image byte array to Base64Encoded String.压缩后,我们将图像字节数组转换为 Base64Encoded 字符串。 After this the string content is exceeding the size limitation of 25KB.在此之后,字符串内容超过了 25KB 的大小限制。 How can i control this size as well?我怎样才能控制这个大小?

We need your help in resolving this.我们需要您的帮助来解决这个问题。 Please help.请帮忙。

JPEG does not support lossless compression. JPEG 不支持无损压缩。 Your best bet will be to use the new Google WebP format .您最好的选择是使用新的Google WebP 格式 It compresses pretty good and is lossless.它压缩得很好而且是无损的。 There is no point in converting it to Base64.将其转换为 Base64 毫无意义。 That is a ridiculous operation when you are trying to keep the data as small as possible.当您试图保持数据尽可能小时,这是一个荒谬的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在数据库中将图像LONGBLOB从数据库转换为base64编码的字符串? - How to convert an image LONGBLOB from the database to base64 encoded string in android? 如何将CQ用户配置文件图像转换为base64编码的字符串 - How to convert cq user profie image to base64 encoded string 如何将图像的字节数组转换为表示jpg的base64编码字符串 - How to convert byte array of an image to a base64 encoded string representing a jpg 如何将 Base64 编码字符串转换为可以在 chrome 浏览器中显示的任何其他图像格式 - How to convert Base64 encoded string to any other image formats which can be displayed in chrome browser 将编码的base64图像转换为Android中的File对象 - Convert encoded base64 image to File object in Android 将Base64编码的图像字符串加载到JLabel中 - Loading Base64 Encoded Image String into JLabel 用Java解码Base64百分比编码的图像字符串 - Decode Base64 percentage encoded Image String in Java java邮件Base64编码字符串到图像附件 - java mail Base64 encoded string to image attachment 如何将base64编码的图像字符串发送到服务器 - how to send base64 encoded string of image to server Java中图像的Base64编码字符串在php中无效 - Base64 encoded string for image in java is not valid in php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM