diff --git a/libvips/foreign/ppmload.c b/libvips/foreign/ppmload.c index f4298246..7f16cb65 100644 --- a/libvips/foreign/ppmload.c +++ b/libvips/foreign/ppmload.c @@ -41,6 +41,10 @@ * - add ppmload_source * 22/11/20 * - fix msb_first default [ewelot] + * 26/12/20 + * - don't byteswap ascii formats + * - set metadata for map loads + * - byteswap binary loads */ /* @@ -705,7 +709,10 @@ vips_foreign_load_ppm_load( VipsForeignLoad *load ) vips_amiMSBfirst() != ppm->msb_first ); #endif /*DEBUG*/ + /* Don't byteswap the ascii formats. + */ if( vips__byteswap_bool( t[0], &t[1], + !ppm->ascii && vips_amiMSBfirst() != ppm->msb_first ) || vips_image_write( t[1], load->real ) ) return( -1 ); diff --git a/test/test-suite/test_foreign.py b/test/test-suite/test_foreign.py index b146c9bd..92104d08 100644 --- a/test/test-suite/test_foreign.py +++ b/test/test-suite/test_foreign.py @@ -891,6 +891,20 @@ class TestForeign: self.save_load("%s.ppm", self.mono) self.save_load("%s.ppm", self.colour) + self.save_load_file("%s.ppm", "[ascii]", self.mono, 0) + self.save_load_file("%s.ppm", "[ascii]", self.colour, 0) + + self.save_load_file("%s.ppm", "[ascii,bitdepth=1]", self.onebit, 0) + + rgb16 = self.colour.colourspace("rgb16") + grey16 = self.mono.colourspace("rgb16") + + self.save_load("%s.ppm", grey16) + self.save_load("%s.ppm", rgb16) + + self.save_load_file("%s.ppm", "[ascii]", grey16, 0) + self.save_load_file("%s.ppm", "[ascii]", rgb16, 0) + @skip_if_no("radload") def test_rad(self): self.save_load("%s.hdr", self.colour)