File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -102,12 +102,7 @@ def encode(self, bufsize):
102102 """
103103
104104 img = self ._T ()
105- shape = img .height , img .width
106-
107- if img .pixel_type != int :
108- shape += 3 ,
109-
110- img .load_array (np .asarray (self .im ).reshape (shape ).tolist ())
105+ img .load_array (np .asarray (self .im ).reshape (img .np_shape ).tolist ())
111106 data = img .export ().bytes ()
112107
113108 return len (data ), 0 , data
Original file line number Diff line number Diff line change @@ -177,6 +177,11 @@ class PictureEntry(SizedEntry):
177177 The type of a single pixel
178178 """
179179
180+ np_shape = (height , width , 3 )
181+ """
182+ The shape of this image as a NumPy array
183+ """
184+
180185 has_color = True
181186 """
182187 Whether this picture has color
@@ -233,10 +238,11 @@ class TIMonoPicture(PictureEntry):
233238
234239 data_width = width // 8
235240 data_height = height
236- data_offset = 0
237241
238242 pil_mode = "L"
239243 pixel_type = int
244+ np_shape = (height , width )
245+
240246 has_color = False
241247
242248 _type_id = 0x07
@@ -288,6 +294,7 @@ class TIPicture(PictureEntry, register=True):
288294
289295 pil_mode = "RGB"
290296 pixel_type = RGB
297+ np_shape = (height , width , 3 )
291298
292299 _type_id = 0x07
293300
@@ -353,6 +360,7 @@ class TIImage(PictureEntry, register=True):
353360
354361 pil_mode = "RGB"
355362 pixel_type = RGB
363+ np_shape = (height , width , 3 )
356364
357365 leading_bytes = b'\x81 '
358366
You can’t perform that action at this time.
0 commit comments