torch/image — pull request #26 by deltheil (2014-10-02 09:15:58+00:00)
Title: ppm: fix header parsing

According to the [spec](http://netpbm.sourceforge.net/doc/ppm.html) there is a _single_ whitespace character right after the max color value. So there is no need to skip characters after the last call to `ppm_get_long`.

Since `ppm_get_long` performs a `getc` behind the scenes, when the max color value decoding terminates the cursor is precisely positioned on the first image byte. Doing an extra `fgets(hdr, 256, fp)` has thus for effect to skip a bunch of pixels, e.g 256/3 ~= 85 pixels for a RGB image:

![bad](https://cloud.githubusercontent.com/assets/355031/4488898/6a58565c-4a14-11e4-8c4a-8664a0d0fb4d.png)

I've included a tiny non-regression test. I think a fancier decoding could even perform a check on the last byte right before the data, like what [VLFeat does](https://github.com/vlfeat/vlfeat/blob/412beb0/vl/pgm.c#L224-L230). But I assume this simple fix is enough so far!