You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter使用image包处理图片后清晰度丢失求解决方案

解决Flutter image包处理后图片清晰度丢失的问题

你的代码里有两处关键问题会导致清晰度下降,修正后即可改善:

  1. 未使用处理后的图片对象
    你已经生成了调整亮度后的brightenedImage,但最终保存的还是原始的image,这属于逻辑错误。把保存代码里的image替换为brightenedImage:

    File('$documentPath/example.jpeg').writeAsBytesSync(img.encodeJpg(brightenedImage!));
    
  2. JPG编码默认压缩质量不足
    image包的encodeJpg方法默认压缩质量不高,会导致画质损耗。手动指定更高的quality参数(取值0-100,数值越高画质越好),比如设为95:

    File('$documentPath/example.jpeg').writeAsBytesSync(img.encodeJpg(brightenedImage!, quality: 95));
    

额外提示:如果原始图片是PNG这类无损格式,转存为JPG本身就会有画质损失,要是需要保留极致清晰度,建议改用encodePng方法保存为PNG格式。

内容的提问来源于stack exchange,提问作者kapil tk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 20:44:56