Similar to costruct, 20230510 - Python Construct - Binary data structure parser, it is kaitai, that is similar but different. I find it more complex but easier to describe the data structure. It is well adopted in radio to decode data frames.
Kaitai is to parse data Not to generate data structures, it is just for reading.
sudo apt-get install python3-kaitaistruct
It is necessary to install the python package kaitaistruct
—
g = Gif.from_file("path/to/some.gif")
print("width = %d" % (g.logical_screen.image_width))
print("height = %d" % (g.logical_screen.image_height))