我正在尝试将图像发送到服务器.在发送之前,我正在减小其尺寸和质量,然后解决任何轮换问题.我的问题是,在旋转图像后,当我保存它时,文件比以前更大.旋转尺寸为10092之前,旋转之后为54226
// Scale image to reduce it
Bitmap reducedImage = reduceImage(tempPhotoPath);
// Decrease photo quality
FileOutputStream fos = new FileOutputStream(tempPhotoFile);
reducedImage.compress(CompressFormat.JPEG, 55, fos);
fos.flush();
fos.close();
// Check and fix rotation issues
Bitmap fixed = fixRotation(tempPhotoPath);
if(fixed!=null)
{
FileOutputStream fos2 = new FileOutputStream(tempPhotoFile);
fixed.compress(CompressFormat.JPEG, 100, fos2);
fos2.flush();
fos2.close();
}
public Bitmap reduceImage(String originalPath)
{
// Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
o.inPurgeable = true;
o.inInputShareable = true;
BitmapFactory.decodeFile(originalPath, o);
// The new size we want to …Run Code Online (Sandbox Code Playgroud)