pydicom.encaps.encapsulate_extended(frames: list[bytes]) tuple[bytes, bytes, bytes][source]

Return encapsulated image data and values for the Extended Offset Table elements.

When using a compressed transfer syntax (such as RLE Lossless or one of JPEG formats) then any Pixel Data must be encapsulated. When many large frames are to be encapsulated, the total length of encapsulated data may exceed the maximum offset available with the Basic Offset Table (2**32 - 1 bytes). Under these circumstances you can:


from pydicom.encaps import encapsulate_extended

# 'frames' is a list of image frames that have been each been encoded
# separately using the compression method corresponding to the Transfer
# Syntax UID
frames: list[bytes] = [...]
out: tuple[bytes, bytes, bytes] = encapsulate_extended(frames)

ds.PixelData = out[0]
ds.ExtendedOffsetTable = out[1]
ds.ExtendedOffsetTableLengths = out[2]

frames (list of bytes) – The compressed frame data to encapsulate, one frame per item.


The (encapsulated frames, extended offset table, extended offset table lengths).

Return type:

bytes, bytes, bytes

See also