encodePngOptimized function

List<int> encodePngOptimized(
  1. Image image, {
  2. required bool optimize,
})

PNG encoder honoring the optimize_png opt-in (upstream #139 / #199). When optimize is true, the image package's max-compression level (9) is used; otherwise its default (level 6) preserves the existing fast generate behavior. Lossless either way.

Implementation

List<int> encodePngOptimized(Image image, {required bool optimize}) {
  return encodePng(image, level: optimize ? 9 : 6);
}