pike.git / lib / modules / Standards.pmod / IIM.pmod

version» Context lines:

pike.git/lib/modules/Standards.pmod/IIM.pmod:1:   // Extracts IPTC Information Interchange Model data (aka "IPTC   // headers") from JPEG files created with PhotoShop.   //   // http://www.iptc.org/IIM/   // - // $Id: IIM.pmod,v 1.6 2007/01/01 04:52:43 nilsson Exp $ + // $Id: IIM.pmod,v 1.7 2007/03/01 14:49:53 grubba Exp $   //   // Anders Johansson & Henrik Grubbström      #pike __REAL_VERSION__      mapping(int:mapping(int:string)) fields =    ([    1: ([ // ENVELOPE RECORD    0: "model version",    5: "destinatino",
pike.git/lib/modules/Standards.pmod/IIM.pmod:130:    return res;    }    //werror("blocks: %O\n", blocks);    foreach(blocks, string block) {    //werror("block: %O\n", String.string2hex(block));    if (sizeof(block) < 6) {    werror("Malformed 8BIM block\n");    continue;    }    -  string block_type_2 = block[..3]; +  string block_type_2; +  int block_length; +  string info; +  +  if (block[0]) { +  // Photoshop 6.0 format with header description text of variable length. +  // The two bytes after the description text is zero padding, then comes +  // the two bytes of data length. +  int dsclen = block[0]; +  //werror("dsclen: %d\n", dsclen); +  block_type_2 = block[1..dsclen]; +  block_length = short_value(block[dsclen+3..dsclen+4]); +  info = block[5+dsclen..4+dsclen+block_length]; +  } +  else { +  block_type_2 = block[..3];    //werror("block_type_2: %O\n", block_type_2); -  int block_length = short_value(block[4..5]); +  block_length = short_value(block[4..5]); +  info = block[6..5 + block_length]; +  }    -  string info = block[6..5 + block_length]; -  +    #if 0    werror("block_length: %O\n"    "actual length: %O\n"    "info: %O\n", block_length, sizeof(info), info);   #endif /* 0 */       while (sizeof(info)) {    if (sizeof(info) < 6) {    //werror("Short info %O\n", info);    break;
pike.git/lib/modules/Standards.pmod/IIM.pmod:190:    string label =    fields[record_set][id] ||    (string)record_set + ":" + (string)id;       if (label == "coded character set") {    if (data == "\e%5") {    res->charset = (res->charset || ({})) + ({ "iso-8859-1" });    }    }    +  if (label == "special instructions" && lower_case(data) == "nyhedstjeneste") +  res->charset = (res->charset || ({})) + ({ "iso-8859-1" }); +     if ((binary_fields[record_set] && binary_fields[record_set][id]) ||    (<3, 7>)[record_set]) {    // Decode binary fields.    data = (string)Gmp.mpz(data, 256);    }       // werror("RAW: %O:%O\n", label, data);       if (res[label])    res[label] += ({ data });