pgm

PGM image not opening


I have a pgm file which is well formatted like this

P2
# CREATOR: GIMP PNM Filter Version 1.1
19 19
0 71 73 74 73 73 74 73 71 70 71 74 72 69 68 71 72 66 69
70 70 74 70 69 69 69 69 71 68 70 72 66 70 71 69 65 68 69
66 72 73 74 74 73 70 73 72 66 70 68 67 68 68 68 67 66 69
66 72 78 74 74 73 71 71 70 70 68 70 66 69 66 65 66 62 62
62 72 76 72 73 75 72 71 68 74 71 68 66 70 65 67 62 56 57
66 70 72 71 72 69 72 73 74 69 65 66 60 64 68 93 99 139 225
240 68 71 70 70 69 70 71 64 64 46 60 57 86 153 206 233 240 244
245 72 69 70 68 67 68 68 68 61 58 82 178 229 236 236 229 238 244
245 74 67 67 70 68 66 69 65 64 97 218 240 242 235 234 240 243 244
244 75 74 73 72 69 68 73 74 128 223 239 242 239 242 243 242 244 241
244 72 76 74 72 69 71 68 83 155 234 242 240 237 242 237 241 240 245
243 72 75 75 71 68 69 65 68 127 237 241 240 241 243 245 244 244 245
244 72 71 69 71 66 66 63 63 107 239 240 244 245 245 246 245 246 246
246 72 70 70 67 64 63 60 74 218 242 245 245 245 245 246 246 247 246
245 73 72 71 70 70 66 61 201 241 244 245 246 245 246 247 246 247 246
247 71 69 71 68 63 61 115 236 239 244 244 245 245 246 246 246 246 246
245 78 72 73 73 68 63 167 243 244 244 245 245 245 246 246 246 246 246
245 75 72 69 71 67 61 218 245 245 246 246 246 246 246 246 246 247 246
246 76 72 72 68 65 74 238 246 246 246 247 246 246 246 246 246 246 246

But trying to open it with "visionneur d'images" on ubuntu i get an error :
enter image description here

Please help me.. I don't know what is the issue.


Solution

  • The number after image dimensions is supposed to be the maximum value in the image. You have it as '0'. Scanning quickly through the data, the value should be 247. Just replace the 0 with 247, using a text editor.