如何在Android中缩小JPEG图像的大小 [英] How to reduce size of JPEG Image in Android

查看:89
本文介绍了如何在Android中缩小JPEG图像的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我正在调用相机应用程序并拍照并将其保存在特定目录(例如/sdcard等)中

In my application, I am invoking the camera application and taking a picture and saving it in a particular directory (E.g. /sdcard etc)

图片被保存为JPEG图像.如何缩小图像尺寸?有可用的图像编码器或压缩功能吗?

The picture is saved as a JPEG image. How do I reduce the size of the image? Is there any available image encoder or compression available?

我在以下位置看到了另一个帖子: Android缩小相机图片的大小

I came across another posting at: Android Reduce Size Of Camera Picture

但这正在缩放图像.我正在寻找可以压缩或编码的东西.有可能吗?

But this is scaling the image. I am looking for something that can compress or encode. Is it possible?

在此先感谢您, 秘鲁的

Thanks In Advance, Perumal

推荐答案

无论如何,我不确定您是否可以尝试此方法.要减小图像的大小,首先应将图像转换为位图,然后再将其保存到特定目录中,然后压缩位图以设置图像的质量并将其写入正确的路径.可以更改图像的质量,希望这将有助于您减小图像的大小.

I am not sure anyway you can try this one.For reducing the size of the image first you should convert the image to bitmap before saving it to the particular directory, and compress the bitmap set the quality of the image and write it to the correct path.The quality of the image can be changed and hope this will help you to reduce the size of the image.

bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);` 

API :

compress (Bitmap.CompressFormat format, int quality, OutputStream stream)

这篇关于如何在Android中缩小JPEG图像的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆