@@ -290,23 +290,40 @@ def from_stream(cls, stream, marker_code, offset):
290290 # horz dots per unit 10 short
291291 # vert dots per unit 12 short
292292 # ------------------ --- ----- -------------------
293- length = stream .read_short (offset )
293+ segment_length = stream .read_short (offset )
294294 density_units = stream .read_byte (offset , 9 )
295295 x_density = stream .read_short (offset , 10 )
296296 y_density = stream .read_short (offset , 12 )
297297 return cls (
298- marker_code , offset , length , density_units , x_density , y_density
298+ marker_code , offset , segment_length , density_units , x_density ,
299+ y_density
299300 )
300301
301302
302303class _SofMarker (_Marker ):
303304 """
304305 Represents a JFIF start of frame (SOFx) marker segment.
305306 """
307+ def __init__ (
308+ self , marker_code , offset , segment_length , px_width , px_height ):
309+ super (_SofMarker , self ).__init__ (marker_code , offset , segment_length )
310+ self ._px_width = px_width
311+ self ._px_height = px_height
312+
306313 @classmethod
307314 def from_stream (cls , stream , marker_code , offset ):
308315 """
309316 Return an |_SofMarker| instance for the SOFn marker at *offset* in
310317 stream.
311318 """
312- raise NotImplementedError
319+ # field off type notes
320+ # ------------------ --- ----- ----------------------------
321+ # segment length 0 short
322+ # Data precision 2 byte
323+ # Vertical lines 3 short px_height
324+ # Horizontal lines 5 short px_width
325+ # ------------------ --- ----- ----------------------------
326+ segment_length = stream .read_short (offset )
327+ px_height = stream .read_short (offset , 3 )
328+ px_width = stream .read_short (offset , 5 )
329+ return cls (marker_code , offset , segment_length , px_width , px_height )
0 commit comments