@@ -283,6 +283,10 @@ class _Chunk(object):
283283 Base class for specific chunk types. Also serves as the default chunk
284284 type.
285285 """
286+ def __init__ (self , chunk_type ):
287+ super (_Chunk , self ).__init__ ()
288+ self ._chunk_type = chunk_type
289+
286290 @classmethod
287291 def from_offset (cls , chunk_type , stream_rdr , offset ):
288292 """
@@ -295,13 +299,28 @@ class _IHDRChunk(_Chunk):
295299 """
296300 IHDR chunk, contains the image dimensions
297301 """
302+ def __init__ (self , chunk_type , px_width , px_height ):
303+ super (_IHDRChunk , self ).__init__ (chunk_type )
304+ self ._px_width = px_width
305+ self ._px_height = px_height
306+
298307 @classmethod
299308 def from_offset (cls , chunk_type , stream_rdr , offset ):
300309 """
301310 Return an _IHDRChunk instance containing the image dimensions
302311 extracted from the IHDR chunk in *stream* at *offset*.
303312 """
304- raise NotImplementedError
313+ px_width = stream_rdr .read_long (offset )
314+ px_height = stream_rdr .read_long (offset , 4 )
315+ return cls (chunk_type , px_width , px_height )
316+
317+ @property
318+ def px_width (self ):
319+ return self ._px_width
320+
321+ @property
322+ def px_height (self ):
323+ return self ._px_height
305324
306325
307326class _pHYsChunk (_Chunk ):
0 commit comments