Browse Source

Set the right png bitdepth (#915)

Joe Cai 3 years ago
parent
commit
e7d1dde5ea
1 changed files with 2 additions and 0 deletions
  1. 2 0
      vips/vips.c

+ 2 - 0
vips/vips.c

@@ -591,6 +591,8 @@ vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace, int quant
   } else {
   } else {
     bitdepth = vips_get_palette_bit_depth(in);
     bitdepth = vips_get_palette_bit_depth(in);
     if (bitdepth) {
     if (bitdepth) {
+      if (bitdepth > 4) bitdepth = 8;
+      else if (bitdepth > 2) bitdepth = 4;
       quantize = 1;
       quantize = 1;
       colors = 1 << bitdepth;
       colors = 1 << bitdepth;
     }
     }