Glide将网络图片压缩成指定大小并保存到本地

private static void toPNG(Context context, String string, File output, int width, int height){
try{
Glide.with(context)
.load(string)
.asBitmap()
.override(width, height)
.get()
.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(output));
}catch (Exception e){
e.printStackTrace();
log(e.getMessage());
}
}
posted @ 2025-11-05 03:11  ganzhijie  阅读(6)  评论(0)    收藏  举报