This commit is contained in:
cwx
2025-02-04 10:58:49 +08:00
parent 2d6b75014b
commit eaf1d70158
2 changed files with 56 additions and 14 deletions
+5 -4
View File
@@ -16,7 +16,6 @@ from concurrent.futures import ThreadPoolExecutor
import hashlib
from io import BytesIO
logger = setup_logging(__name__)
class ImageInfo:
@@ -171,7 +170,7 @@ class ImageInfo:
('.png', '.jpg', '.jpeg', '.gif', '.bmp')
):
continue
try:
with zf.open(file_info) as file:
# 读取前 chunk_size 字节用于解析元数据
@@ -182,13 +181,13 @@ class ImageInfo:
page = ComicPageInfo()
page.Key = self.get_image_hash_advanced(img_buffer)
# 使用 Pillow 解析图像信息
with Image.open(img_buffer) as img:
page.Image = file_info.filename.split(".")[0]
page.ImageSize = file_info.file_size
ImageWidth, ImageHeight = zip(img.size)
page.ImageWidth, page.ImageHeight = [ImageWidth[0], ImageHeight[0]]
page.ImageWidth, page.ImageHeight = [ImageWidth[0], ImageHeight[0]]
#metadata = {
# "filename": file_info.filename,
# "compressed_size": file_info.compress_size,
@@ -342,6 +341,8 @@ class ComicInfoXml:
cpi.ImageSize = page.ImageSize
cpi.Key = page.Key
cpi.ImageWidth = page.ImageWidth
if page.ImageWidth != 720:
print(cpi)
cpi.ImageHeight = page.ImageHeight
page_elem = ET.SubElement(pages_elem, 'Page', cpi.toString())
else: