@@ -89,16 +89,6 @@ def __init__(
89
89
self ._image_resize = image_resize
90
90
self ._image_position = image_position
91
91
self ._image_dim_json_path = image_dim_json_path
92
- if image_json_path or image_url_path :
93
- if self ._debug :
94
- print ("Init image path" )
95
- if not self ._image_position :
96
- self ._image_position = (0 , 0 ) # default to top corner
97
- if not self ._image_resize :
98
- self ._image_resize = (
99
- self .display .width ,
100
- self .display .height ,
101
- ) # default to full screen
102
92
103
93
gc .collect ()
104
94
@@ -160,59 +150,53 @@ def process_image(self, json_data, sd_card=False):
160
150
print ("image dim:" , iwidth , iheight )
161
151
162
152
if image_url :
163
- try :
164
- print ("original URL:" , image_url )
165
- if self ._convert_image :
166
- if iwidth < iheight :
167
- image_url = self .image_converter_url (
168
- image_url ,
169
- int (
170
- self ._image_resize [1 ]
171
- * self ._image_resize [1 ]
172
- / self ._image_resize [0 ]
173
- ),
174
- self ._image_resize [1 ],
175
- )
176
- else :
177
- image_url = self .image_converter_url (
178
- image_url , self ._image_resize [0 ], self ._image_resize [1 ]
179
- )
180
-
181
- print ("convert URL:" , image_url )
182
- # convert image to bitmap and cache
183
- # print("**not actually wgetting**")
184
- filename = "/cache.bmp"
185
- chunk_size = 4096 # default chunk size is 12K (for QSPI)
186
- if sd_card :
187
- filename = "/sd" + filename
188
- chunk_size = 512 # current bug in big SD writes -> stick to 1 block
189
- try :
190
- self .wget (image_url , filename , chunk_size = chunk_size )
191
- except OSError as error :
192
- raise OSError (
193
- """\n \n No writable filesystem found for saving datastream. Insert an SD card or set internal filesystem to be unsafe by setting 'disable_concurrent_write_protection' in the mount options in boot.py""" # pylint: disable=line-too-long
194
- ) from error
195
- except RuntimeError as error :
196
- raise RuntimeError ("wget didn't write a complete file" ) from error
153
+ print ("original URL:" , image_url )
154
+ if self ._convert_image :
197
155
if iwidth < iheight :
198
- pwidth = int (
199
- self ._image_resize [1 ]
200
- * self ._image_resize [1 ]
201
- / self ._image_resize [0 ]
202
- )
203
- position = (
204
- self ._image_position [0 ]
205
- + int ((self ._image_resize [0 ] - pwidth ) / 2 ),
206
- self ._image_position [1 ],
156
+ image_url = self .image_converter_url (
157
+ image_url ,
158
+ int (
159
+ self ._image_resize [1 ]
160
+ * self ._image_resize [1 ]
161
+ / self ._image_resize [0 ]
162
+ ),
163
+ self ._image_resize [1 ],
207
164
)
208
165
else :
209
- position = self ._image_position
166
+ image_url = self .image_converter_url (
167
+ image_url , self ._image_resize [0 ], self ._image_resize [1 ]
168
+ )
210
169
211
- except ValueError as error :
212
- print ("Error displaying cached image. " + error .args [0 ])
213
- self .set_background (self ._default_bg )
214
- finally :
215
- image_url = None
216
- gc .collect ()
170
+ print ("convert URL:" , image_url )
171
+ # convert image to bitmap and cache
172
+ # print("**not actually wgetting**")
173
+ filename = "/cache.bmp"
174
+ chunk_size = 4096 # default chunk size is 12K (for QSPI)
175
+ if sd_card :
176
+ filename = "/sd" + filename
177
+ chunk_size = 512 # current bug in big SD writes -> stick to 1 block
178
+ try :
179
+ self .wget (image_url , filename , chunk_size = chunk_size )
180
+ except OSError as error :
181
+ raise OSError (
182
+ """\n \n No writable filesystem found for saving datastream. Insert an SD card or set internal filesystem to be unsafe by setting 'disable_concurrent_write_protection' in the mount options in boot.py""" # pylint: disable=line-too-long
183
+ ) from error
184
+ except RuntimeError as error :
185
+ raise RuntimeError ("wget didn't write a complete file" ) from error
186
+ if iwidth < iheight :
187
+ pwidth = int (
188
+ self ._image_resize [1 ]
189
+ * self ._image_resize [1 ]
190
+ / self ._image_resize [0 ]
191
+ )
192
+ position = (
193
+ self ._image_position [0 ] + int ((self ._image_resize [0 ] - pwidth ) / 2 ),
194
+ self ._image_position [1 ],
195
+ )
196
+ else :
197
+ position = self ._image_position
198
+
199
+ image_url = None
200
+ gc .collect ()
217
201
218
202
return filename , position
0 commit comments