@@ -19,14 +19,18 @@ def read(f, out, settings=None):
1919 # Metadata started appearing in V4
2020 # Threads appeared in V5.
2121 # We quickly abort if there are any complex items in the header.
22- if pes_string == "PES0100" :
22+ if pes_string == "# PES0100" :
2323 out .metadata ("version" , 10 )
24+ read_pes_header_version_10 (f , out , loaded_thread_values )
2425 elif pes_string == "#PES0090" :
2526 out .metadata ("version" , 9 )
27+ read_pes_header_version_9 (f , out , loaded_thread_values )
2628 elif pes_string == "#PES0080" :
2729 out .metadata ("version" , 8 )
30+ read_pes_header_version_8 (f , out , loaded_thread_values )
2831 elif pes_string == "#PES0070" :
2932 out .metadata ("version" , 7 )
33+ read_pes_header_version_7 (f , out , loaded_thread_values )
3034 elif pes_string == "#PES0060" :
3135 out .metadata ("version" , 6 )
3236 read_pes_header_version_6 (f , out , loaded_thread_values )
@@ -146,3 +150,99 @@ def read_pes_header_version_6(f, out, threadlist):
146150 count_threads = read_int_16le (f )
147151 for i in range (0 , count_threads ):
148152 read_pes_thread (f , threadlist )
153+
154+
155+ def read_pes_header_version_7 (f , out , threadlist ):
156+ f .seek (4 , 1 )
157+ read_pes_metadata (f , out )
158+ f .seek (36 , 1 )
159+ v = read_pes_string (f )
160+ if v is not None and len (v ) > 0 :
161+ out .metadata ("image_file" , v )
162+ f .seek (24 , 1 )
163+ count_programmable_fills = read_int_16le (f )
164+ if count_programmable_fills != 0 :
165+ return
166+ count_motifs = read_int_16le (f )
167+ if count_motifs != 0 :
168+ return
169+ count_feather_patterns = read_int_16le (f )
170+ if count_feather_patterns != 0 :
171+ return
172+ count_threads = read_int_16le (f )
173+ for i in range (0 , count_threads ):
174+ read_pes_thread (f , threadlist )
175+
176+
177+ def read_pes_header_version_8 (f , out , threadlist ):
178+ f .seek (4 , 1 )
179+ read_pes_metadata (f , out )
180+ f .seek (38 , 1 )
181+ v = read_pes_string (f )
182+ if v is not None and len (v ) > 0 :
183+ out .metadata ("image_file" , v )
184+ f .seek (26 , 1 )
185+ count_programmable_fills = read_int_16le (f )
186+ if count_programmable_fills != 0 :
187+ return
188+ count_motifs = read_int_16le (f )
189+ if count_motifs != 0 :
190+ return
191+ count_feather_patterns = read_int_16le (f )
192+ if count_feather_patterns != 0 :
193+ return
194+ count_threads = read_int_16le (f )
195+ for i in range (0 , count_threads ):
196+ read_pes_thread (f , threadlist )
197+
198+
199+ def read_pes_header_version_9 (f , out , threadlist ):
200+ f .seek (4 , 1 )
201+ read_pes_metadata (f , out )
202+ f .seek (14 , 1 )
203+ v = read_pes_string (f )
204+ if v is not None and len (v ) > 0 :
205+ out .metadata ("hoop_name" , v )
206+ f .seek (30 , 1 ) # this is 36 in version 6 and 24 in version 5
207+ v = read_pes_string (f )
208+ if v is not None and len (v ) > 0 :
209+ out .metadata ("image_file" , v )
210+ f .seek (34 , 1 )
211+ count_programmable_fills = read_int_16le (f )
212+ if count_programmable_fills != 0 :
213+ return
214+ count_motifs = read_int_16le (f )
215+ if count_motifs != 0 :
216+ return
217+ count_feather_patterns = read_int_16le (f )
218+ if count_feather_patterns != 0 :
219+ return
220+ count_threads = read_int_16le (f )
221+ for i in range (0 , count_threads ):
222+ read_pes_thread (f , threadlist )
223+
224+
225+ def read_pes_header_version_10 (f , out , threadlist ):
226+ f .seek (4 , 1 )
227+ read_pes_metadata (f , out )
228+ f .seek (14 , 1 )
229+ v = read_pes_string (f )
230+ if v is not None and len (v ) > 0 :
231+ out .metadata ("hoop_name" , v )
232+ f .seek (38 , 1 )
233+ v = read_pes_string (f )
234+ if v is not None and len (v ) > 0 :
235+ out .metadata ("image_file" , v )
236+ f .seek (34 , 1 )
237+ count_programmable_fills = read_int_16le (f )
238+ if count_programmable_fills != 0 :
239+ return
240+ count_motifs = read_int_16le (f )
241+ if count_motifs != 0 :
242+ return
243+ count_feather_patterns = read_int_16le (f )
244+ if count_feather_patterns != 0 :
245+ return
246+ count_threads = read_int_16le (f )
247+ for i in range (0 , count_threads ):
248+ read_pes_thread (f , threadlist )
0 commit comments