From 4c838fb1ed99c43bf25e55d0358ef3a7bfa1ab90 Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Tue, 6 Dec 2022 17:48:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/CBZUtils.py | 5 +++++ utils/ImageUtils.py | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/utils/CBZUtils.py b/utils/CBZUtils.py index a795195..3f69087 100644 --- a/utils/CBZUtils.py +++ b/utils/CBZUtils.py @@ -48,5 +48,10 @@ class CBZUtils: def packAutoComicChapterCBZ(cls): chapter_path = comicInfo.getDirComicChapter() packCBZ_path = comicInfo.getDirCBZComicChapter() + if os.path.exists(chapter_path): + dirs = os.listdir(chapter_path) + for file in dirs: + if file.startswith("scramble="): + os.remove(file) cls.zip_compression(chapter_path,packCBZ_path+".CBZ") comicInfo.nextCBZToDoneChapter() \ No newline at end of file diff --git a/utils/ImageUtils.py b/utils/ImageUtils.py index a4978c0..e87ef6b 100644 --- a/utils/ImageUtils.py +++ b/utils/ImageUtils.py @@ -54,7 +54,7 @@ class imageUtils: if image_su == "downloads": return None cls.splitimage(file_path,blocks,1,split_path) - cls.image_compose(split_path+"/",blocks,1,save_file_path,blockHeight,width) + cls.image_compose(split_path,blocks,1,save_file_path,blockHeight,width) #完成后清空 return file_path @@ -85,6 +85,7 @@ class imageUtils: else: print('不数!') img.close + return src @classmethod def image_compose(cls,src,row,column,save_path,image_height,image_width): @@ -102,7 +103,7 @@ class imageUtils: img_nums=len(img_list) image_names = [] for i in range(img_nums): - img_name=src+img_list[i] + img_name=os.path.join(src,img_list[i]) image_names.append(img_name) #使用倒序 image_names = image_names[::-1] @@ -115,13 +116,14 @@ class imageUtils: for y in range(1, row + 1): for x in range(1, column + 1): #1 * (row=1 -1) col=1 -1 - image_path = src + image_names[column * (y - 1) + x - 1] + image_path = image_names[column * (y - 1) + x - 1] print("split_image=",image_path) from_image = Image.open(image_path) #保持原图片大小 #.resize( # (image_size, image_size),Image.ANTIALIAS) to_image.paste(from_image, ((x - 1) * image_size, (y - 1) * image_size)) + from_image.close() to_image.save(save_path) print("图片合并完成:", save_path) shutil.rmtree(src) @@ -130,5 +132,6 @@ class imageUtils: @classmethod def getScrambleImage(cls,path): scrambleFileCache = cls.scrambleImage(path) - if os.path.exists(scrambleFileCache): - os.remove(scrambleFileCache) \ No newline at end of file + if not scrambleFileCache == None: + if os.path.exists(scrambleFileCache): + os.remove(scrambleFileCache) \ No newline at end of file