缩放
public static void resize(Bitmap bitmap, File outputFile, int maxWidth, int maxHeight) { try { int bitmapWidth = bitmap.getWidth(); int bitmapHeight = bitmap.getHeight(); // 图片大于最大高宽,按大的值缩放 if (bitmapWidth > maxHeight || bitmapHeight > maxWidth) { float widthScale = maxWidth * 1.0f / bitmapWidth; float heightScale = maxHeight * 1.0f / bitmapHeight; //取小值 float scale = Math.min(widthScale, heightScale); Matrix matrix = new Matrix(); //图片变换处理 缩放 matrix.postScale(scale, scale); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmapWidth, bitmapHeight, matrix, false); } FileOutputStream out = new FileOutputStream(outputFile); try { bitmap.compress(Bitmap.CompressFormat.JPEG, 80, out); } catch (Exception e) { e.printStackTrace(); } finally