c996af2d by 周伟奇

add flag

1 parent 77132c68
...@@ -1339,8 +1339,8 @@ class Command(BaseCommand, LoggerMixin): ...@@ -1339,8 +1339,8 @@ class Command(BaseCommand, LoggerMixin):
1339 pdf_handler.extract_image(max_img_count) 1339 pdf_handler.extract_image(max_img_count)
1340 end_time = time.time() 1340 end_time = time.time()
1341 speed_time = int(end_time - start_time) 1341 speed_time = int(end_time - start_time)
1342 self.online_log.info('{0} [pdf to img end] [task={1}] [times={2}] [spend_time={3}]'.format( 1342 self.online_log.info('{0} [pdf to img end] [task={1}] [times={2}] [spend_time={3}] [is_new_modify={4}]'.format(
1343 self.log_base, task_str, times, speed_time)) 1343 self.log_base, task_str, times, speed_time, pdf_handler.is_new_modify))
1344 except Exception as e: 1344 except Exception as e:
1345 self.online_log.warn('{0} [download or pdf to img failed] [task={1}] [times={2}] ' 1345 self.online_log.warn('{0} [download or pdf to img failed] [task={1}] [times={2}] '
1346 '[error={3}]'.format(self.log_base, task_str, times, 1346 '[error={3}]'.format(self.log_base, task_str, times,
......
...@@ -63,6 +63,7 @@ class PDFHandler: ...@@ -63,6 +63,7 @@ class PDFHandler:
63 self.img_dir_path = img_dir_path 63 self.img_dir_path = img_dir_path
64 self.img_path_list = [] 64 self.img_path_list = []
65 self.img_count = 0 65 self.img_count = 0
66 self.is_new_modify = 0 # 用于记录受新改动影响的PDF
66 self.xref_set = set() 67 self.xref_set = set()
67 self.img_suffixs = {'.jpeg', '.jpg', '.png', '.webp', '.bmp'} 68 self.img_suffixs = {'.jpeg', '.jpg', '.png', '.webp', '.bmp'}
68 self.suffix = self.get_suffix(document_name) 69 self.suffix = self.get_suffix(document_name)
...@@ -246,8 +247,8 @@ class PDFHandler: ...@@ -246,8 +247,8 @@ class PDFHandler:
246 self.xref_set.add(xref) 247 self.xref_set.add(xref)
247 self.img_path_list.append(img_save_path) 248 self.img_path_list.append(img_save_path)
248 249
249 @staticmethod 250 # @staticmethod
250 def split_il(il): 251 def split_il(self, il):
251 broken_il = [] 252 broken_il = []
252 start = 0 253 start = 0
253 length = len(il) 254 length = len(il)
...@@ -258,6 +259,7 @@ class PDFHandler: ...@@ -258,6 +259,7 @@ class PDFHandler:
258 page_to_png = True 259 page_to_png = True
259 break 260 break
260 if il[i][2] >= TINY_IMG_MAX_WIDTH: 261 if il[i][2] >= TINY_IMG_MAX_WIDTH:
262 self.is_new_modify = 1
261 page_to_png = True 263 page_to_png = True
262 break 264 break
263 else: 265 else:
...@@ -460,6 +462,7 @@ class PDFHandler: ...@@ -460,6 +462,7 @@ class PDFHandler:
460 self.page_to_png(page) 462 self.page_to_png(page)
461 # 大图 463 # 大图
462 elif width >= WH_COUPLE_6[0] or height >= WH_COUPLE_6[1]: 464 elif width >= WH_COUPLE_6[0] or height >= WH_COUPLE_6[1]:
465 self.is_new_modify = 1
463 is_big_img = (width < WH_COUPLE_7[0] and height < WH_COUPLE_7[1]) # 防止图片过大 466 is_big_img = (width < WH_COUPLE_7[0] and height < WH_COUPLE_7[1]) # 防止图片过大
464 page = pdf.loadPage(pno) 467 page = pdf.loadPage(pno)
465 self.page_to_png(page, is_big_img=is_big_img) 468 self.page_to_png(page, is_big_img=is_big_img)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!