2

I have ppm file X.ppm with comment :

 xxd X.ppm|head -10
0000000: 5036 0a23 206d 6967 6874 796d 616e 6465  P6.# mightymande
0000010: 6c20 2d32 2e38 3034 3132 3232 3037 3833  l -2.80412220783
0000020: 3834 3132 3833 3535 3139 3235 652d 3032  841283551925e-02
0000030: 202b 2036 2e39 3438 3932 3238 3438 3134   + 6.94892284814
0000040: 3730 3430 3430 3831 3238 3631 652d 3031  704040812861e-01
0000050: 2069 2040 2034 2e34 3430 3839 3230 3938   i @ 4.440892098
0000060: 3530 3036 3237 3165 2d31 360a 3132 3830  5006271e-16.1280
0000070: 2037 3230 0a32 3535 0aff ffff ffff ffff   720.255........
0000080: ffff ffff ffff ffff ffff ffff ffff fefe  ................
0000090: fefc fcfc f8f8 f8e8 e8e8 4141 4140 4040  ..........AAA@@@

It is created with c code :

 void record_write(FILE *out, unsigned char *buffer, int width, int height, mpfr_t centerx, mpfr_t centery, mpfr_t radius) {
  fprintf(out, "P6\n");
  mpfr_fprintf(out, "# mightymandel %Re + %Re i @ %Re\n", centerx, centery, radius);
  fprintf(out, "%d %d\n255\n", width, height);
  fflush(out);
  for (int y = height - 1; y >= 0; --y) {
    fwrite(buffer + y * width * 3, width * 3, 1, out);
  }
  fflush(out);
}

I can convert it to png :

xxd X.png|head -10
0000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452  .PNG........IHDR
0000010: 0000 0500 0000 02d0 0802 0000 0137 187a  .............7.z
0000020: 9700 0000 5f74 4558 7454 6974 6c65 002d  ...._tEXtTitle.-
0000030: 322e 3830 3431 3232 3230 3738 3338 3431  2.80412220783841
0000040: 3238 3335 3531 3932 3565 2d30 3220 2b20  283551925e-02 + 
0000050: 362e 3934 3839 3232 3834 3831 3437 3034  6.94892284814704
0000060: 3034 3038 3132 3836 3165 2d30 3120 6920  040812861e-01 i 
0000070: 4020 342e 3434 3038 3932 3039 3835 3030  @ 4.440892098500
0000080: 3632 3731 652d 3136 aba5 7721 0000 0015  6271e-16..w!....
0000090: 7445 5874 536f 6674 7761 7265 006d 6967  tEXtSoftware.mig

It also contain comment, but :

What program should I use to extract comment from ppm files ?

2

Using Image Magic :

identify -format "%c" X.ppm

using head and tail ( from program mightymandel by Claude Heiland-Allen

head -n 2 1.ppm | tail -n 1
  • @HalosGhost. Thx for the edit. Could you describe what have you changed ? TIA – Adam Dec 23 '14 at 17:27
  • I added a space (you need four at the beginning of a line for a code block, you only had three) :D – HalosGhost Dec 23 '14 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.