Skip to content

类似韩国漫画的多章节的合并 #423

@Lee878

Description

@Lee878

目前在下载韩国漫画的时候,出现多章节想合并成一个PDF,应该怎么合并。目前查看是在删除掉过小的图片后,还是报错
image
以下是删除过小图片的代码

import os
from PIL import Image

# 设置主目录路径,例如 '/A/'
main_folder = r"./jm/1114754"

def check_image_size(image_path):
    """检查图片尺寸"""
    try:
        with Image.open(image_path) as img:
            width, height = img.size
            return width, height
    except Exception as e:
        print(f"无法打开图片 {image_path},错误: {e}")
        return None, None

def delete_small_images(folder):
    """递归遍历文件夹,删除小于 3x3 的图片"""
    for root, _, files in os.walk(folder):  # 遍历所有子目录
        for filename in files:
            if filename.lower().endswith(('png', 'jpg', 'jpeg', 'webp')):  # 过滤图片格式
                img_path = os.path.join(root, filename)
                width, height = check_image_size(img_path)
                if width is not None and (width < 3 or height < 3):
                    print(f"删除过小图片: {img_path} ({width}x{height})")
                    os.remove(img_path)

# 执行递归检查
delete_small_images(main_folder)


# resize_images("/comic/边缘人的复仇")

以下是我的代码

#!/usr/bin/env python3

import sys

import jmcomic
from jmcomic import *
args = sys.argv[1:]

option = jmcomic.JmOption.construct(
    {
        "dir_rule": {"base_dir": "./jm/1114754"},
        "download": {"image": {"suffix": ".jpg"}},
        "plugins": {
            # "after_album": [
            #     {
            #         "plugin": "img2pdf",
            #         "kwargs": {
            #             "pdf_dir": "./pdf/1114754",
            #             "filename_rule": "Aname",
            #         },
            #     }
            # ]
            "call_img2pdf": [
                {
                    "plugin": "img2pdf",
                    "kwargs": {
                        "pdf_dir": "./pdf/1114754",
                        "filename_rule": "Aname",
                    },
                }
            ]
        },
    },
    cover_default=True,
)

# for arg in args:
#     print("Downloading %s..." % arg)
#     jmcomic.download_album(arg, option)
album = option.new_jm_client().get_album_detail(1114754)
option.call_all_plugin('call_img2pdf', album=album)
print("All downloads finished")

Originally posted by @Lee878 in #327 (reply in thread)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions