[Image-SIG] Embedded ICC profiles - updated JPEG patch

Florian Höch lists+Image_SIG at hoech.org
Sun Feb 24 13:30:51 CET 2008


Just noticed that the JPEG patch I suggested would not succeed in 
retrieving ICC profiles larger than 64K, because these would be split 
across multiple APP2 markers. New code:

JpegImagePlugin.py

83a84,105
 >     elif marker == 0xFFE2 and s[:12] == "ICC_PROFILE\0":
 >         # Since an ICC profile can be larger than the maximum size of
 >         # a JPEG marker (64K), we need provisions to split it into
 >         # multiple markers. The format defined by the ICC specifies
 >         # one or more APP2 markers containing the following data:
 >         #   Identifying string      ASCII "ICC_PROFILE\0"  (12 bytes)
 >         #   Marker sequence number  1, 2, etc (1 byte)
 >         #   Number of markers       Total of APP2's used (1 byte)
 >         #   Profile data            (remainder of APP2 data)
 >         # Decoders should use the marker sequence numbers to
 >         # reassemble the profile, rather than assuming that the APP2
 >         # markers appear in the correct sequence.
 >         if not self.info.has_key("icc_profile"):
 >             self.icc_profile_marker_prev = "\0"
 >             self.info["icc_profile"] = ""
 >         icc_profile_marker_curr = s[12]
 >         if self.icc_profile_marker_prev < icc_profile_marker_curr:
 >             self.info["icc_profile"] += s[14:]
 >         else:
 >             self.info["icc_profile"] = s[14:] + \
 >             self.info["icc_profile"]
 >         self.icc_profile_marker_prev = icc_profile_marker_curr

Regards,

Florian


More information about the Image-SIG mailing list