Menu ▾ ▴

Photoshop 'Anno' block

Developers
blue-j
4 days ago
4 days ago
  • blue-j

    blue-j - 4 days ago

    Photoshop's Notes tool stores annotations in a tagged block with key Anno in the global tagged-block area of the layer-and-mask-information section** of PSD/PSB files — after the layer info sub-section and the global layer mask, in the same tagged-block list as Patt/FMsk/CAI etc. Adobe's spec documents it — the "Annotations (Photoshop 6.0)" section gives the full field layout and names the block: "Key is 'Anno'".

    Photoshop 2026 still writes this block (the sample was made in Photoshop 2026, July 2026). Notes placed outside the canvas are stored with negative coordinates.

    Path from the top of a PSD: header (26 B) → color mode data (4-B length + data) → image resources (4-B length + data) → layer & mask information section (4-B length, 8-B in PSB):

    layer & mask info section:
      [4|8]  layer info length          (0 in a flattened file)
      [...]  layer info
      [4]    global layer mask length
      [...]  global layer mask
      [...]  global tagged blocks:      sig '8BIM'|'8B64' + key + [4|8] length + data
             ^^^ 'Anno' lives here      (data padded to a multiple of 4;
                                         length field excludes the pad)
    

    ExifTool's ProcessLayersAndMask currently parses the layer info sub-section and then seeks directly to the end of the whole section — the global tagged-block area is never walked. ExifTool's per-layer walk (ProcessLayers) decides a block has an 8-byte length only from the PSB-plus-key-list test — it keys off the block key, not the signature. ProcessLayers has a comment wondering whether the 8B64 signature itself indicates a 64-bit length ("it would be great if '8B64' indicated a 64-bit version… but it is not mentioned in the specification").

    Confirmed: a PSB written by Photoshop 2026 contains global blocks 8B64 FMsk and 8B64 cinf, both with 8-byte length fields. cinf is not in the known 8-byte-key list, so reading its length as 4 bytes yields 0 and derails the scan; reading it as 8 bytes (410) lands exactly on the section end.

    ag-psd already resolves this well (its psdReader uses sig === '8B64' || (large && largeAdditionalInfoKeys.includes(key))), and the Anno scan added here does the same: 8-byte length if the signature is 8B64, OR the file is PSB and the key is in the known list (LMsk Lr16 Lr32 Layr Mt16 Mt32 Mtrn Alph FMsk lnk2 FEid FXid PxSD). Since the added scan only needs to reach Anno, and Anno itself is a plain 4-byte-length 8BIM block, this mostly matters for not tripping over 8B64 siblings on the way.

    Block structure

    Anno block data (all big-endian):

    size field
    2 major version = 2
    2 minor version = 1
    4 annotation count

    Then per annotation:

    size field
    4 record length (from the start of this field)
    4 type: txtA (text) or sndA (sound)
    1 open flag (popup expanded)
    1 flags (Photoshop writes 0x1C)
    2 optional blocks = 1
    16 icon rect: top, left, bottom, right — signed int32; off-canvas notes are negative
    16 popup rect: top, left, bottom, right — signed int32
    10 color: 2-B color space + four 2-B components (default is PS yellow: space 0, FFFF FFFF 8383 0000)
    var author — Pascal string, padded to even total length
    var name — Pascal string, padded (usually empty)
    var modification date — Pascal string, padded; PDF-style D:YYYYMMDDHHMMSS±HH'MM'
    4 content length (= 12 + data length)
    4 content key: txtC (text) or sndM (sound)
    4 data length
    var data — text: 0xFEFF BOM + UTF-16BE (spec: "ASCII or Unicode string"); \r line endings. Sound: WAV bytes

    The spec describes the text as "ASCII or Unicode string". In practice current Photoshop always writes a 0xFEFF BOM + UTF-16BE payload. If a note ever lacked the BOM, the ASCII/8-bit fallback would be interpreted in the platform charset (MacRoman on Mac) like other Photoshop Pascal strings — the patch decodes that fallback via CharsetPhotoshop, but note the fixtures here only exercise the BOM+UTF-16BE path. Decode BOM text as UTF-16, not UCS-2, so non-BMP characters (emoji, stored as surrogate pairs) survive; UCS-2 emits each surrogate half separately and yields invalid UTF-8.

    The note anchor position is the icon rect's (left, top). Pascal strings use the platform charset like other Photoshop Pascal strings (ExifTool's CharsetPhotoshop option applies; Mac-authored files need -charset photoshop=mac for non-ASCII authors). The PDF-style date is no accident — the PS6-era Notes feature was built for PDF annotation interoperability; the timezone can in principle be ±HH'mm', Z, or absent, so a date parser should tolerate all three (current Photoshop writes ±HH'mm').

     
  • blue-j

    blue-j - 4 days ago

    Encore!

     
  • blue-j

    blue-j - 4 days ago

    Oh - I couldn't get access to a note with a sound file from older Photoshops. It will be an embedded .wav So this is not included in all this.

     

Log in to post a comment.