7fd988ed by chenyao

更改从pdf中切图的方式

1 parent a0d6443d
......@@ -10,9 +10,9 @@ from io import BytesIO
from unicodedata import normalize
# 页面保存为png图片参数
ZOOM_X_1 = ZOOM_Y_1 = 1.0
ZOOM_X_2 = ZOOM_Y_2 = 2.0
ZOOM_X_3 = ZOOM_Y_3 = 3.0
ZOOM_X_1 = ZOOM_Y_1 = 3.0
ZOOM_X_2 = ZOOM_Y_2 = 5.0
ZOOM_X_3 = ZOOM_Y_3 = 7.0
trans_1 = fitz.Matrix(ZOOM_X_1, ZOOM_X_1).preRotate(0) # zoom factor 1 in each dimension
trans_2 = fitz.Matrix(ZOOM_X_2, ZOOM_X_2).preRotate(0) # zoom factor 2 in each dimension
trans_3 = fitz.Matrix(ZOOM_X_3, ZOOM_X_3).preRotate(0) # zoom factor 3 in each dimension
......@@ -345,7 +345,7 @@ class PDFHandler:
# 3.3 碎图分组大于2、全过滤、含特殊filter,特殊处理:整个页面保存为png图片
if page_to_png:
page = pdf.loadPage(pno)
self.page_to_png(page)
self.page_to_png(page, is_big_img=True)
def title_is_ebank(self, char):
new_char = normalize('NFKC', char)
......@@ -450,7 +450,7 @@ class PDFHandler:
# 1.页面图片对象数目为0时,保存整个页面为png图片
if self.is_e_pdf or self.is_ebank or len(il) == 0:
page = pdf.loadPage(pno)
self.page_to_png(page)
self.page_to_png(page, is_big_img=True)
# 2.页面图片对象数目为1时:
# 小图(如电子账单的盖章):保存整个页面为png图片
# 大图:提取图片对象
......@@ -459,13 +459,13 @@ class PDFHandler:
# 小图
if width < WH_COUPLE_1[0] and height < WH_COUPLE_1[1]:
page = pdf.loadPage(pno)
self.page_to_png(page)
self.page_to_png(page, is_big_img=True)
# 大图
elif width >= WH_COUPLE_6[0] or height >= WH_COUPLE_6[1]:
self.is_new_modify = 1
is_big_img = (width < WH_COUPLE_7[0] and height < WH_COUPLE_7[1]) # 防止图片过大
page = pdf.loadPage(pno)
self.page_to_png(page, is_big_img=is_big_img)
self.page_to_png(page, is_big_img=True)
elif xref not in self.xref_set:
self.extract_single_image(pdf, xref, smask, colorspace, pno)
# 3.页面图片对象数目大于1时,特殊处理
......@@ -480,7 +480,7 @@ class PDFHandler:
with fitz.Document(self.path) as pdf:
for pno in range(pdf.pageCount):
page = pdf.loadPage(pno)
self.page_to_png(page)
self.page_to_png(page, is_big_img=True)
self.img_count = len(self.img_path_list)
def ebank_draw(self):
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!