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/ - // +    // Anders Johansson & Henrik Grubbström      #pike __REAL_VERSION__    -  + //! IPTC Information Interchange Model data + //! (aka "IPTC header") extraction. + //! + //! @url{http://www.iptc.org/IIM/@} +    mapping(int:mapping(int:string)) fields =    ([    1: ([ // ENVELOPE RECORD    0: "model version",    5: "destinatino",    20: "file format",    22: "file format version",    30: "service identifier",    40: "envelope number",    50: "product i.d.",
pike.git/lib/modules/Standards.pmod/IIM.pmod:248:       if (res[label])    res[label] += ({ data });    else    res[label] = ({ data });    }    }    return res;   }    + //! Get IPTC information from an open file. + //! + //! Supported embedding formats are: + //! + //! @ul + //! @item + //! PhotoShop Document (aka PSD). + //! @item + //! Postscript and Embedded Postscript. + //! @item + //! Joint Picture Experts Group (aka JPEG). + //! @endul + //! + //! @returns + //! Returns a mapping containing any found IPTC IIM data.   mapping get_information(Stdio.File fd)   {    string marker = fd->read(2);    string photoshop_data = "";       if (marker == "\xc5\xd0") {    // Probably a DOS EPS Binary Header.    string tmp = fd->read(28);    if (!has_prefix(tmp, "\xd3\xc6")) return ([]);    int offset;
pike.git/lib/modules/Standards.pmod/IIM.pmod:312:    //werror ("length: %O\n", short_value(length_s));       string data = fd->read((length-2) & 0xffff);    if (app == "\xff\xed") // APP14 Photoshop    {    //werror("data: %O\n", data);    photoshop_data = data;    break;    }    } while (1); +  } else if (marker == "8B") { +  // May be a native PSD file. It should start with "8BPS\0\1" to be valid. +  string marker2 = fd->read(4); +  if (marker2 == "PS\0\1") { +  photoshop_data = "8BPS\0\1" + fd->read(); +  }    } else {    //werror("unknown marker: %O neither JPEG nor Postscript\n", marker);    return ([]);    }       if (!sizeof(photoshop_data)) return ([]);       mapping res = decode_photoshop_data(photoshop_data);       if (sizeof(res)) {