1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-11 00:36:33 +00:00

fix truncated file read (#1133)

This commit is contained in:
Alex Xu
2025-10-21 20:41:18 -07:00
committed by GitHub
parent fb9b3c676b
commit 2d288f72ea
5 changed files with 15 additions and 5 deletions

View File

@@ -24,10 +24,12 @@ import sys
from argparse import ArgumentParser
from shutil import rmtree
from multiprocessing import Pool
from PIL import Image, ImageChops, ImageOps, ImageDraw, ImageFilter
from PIL import Image, ImageChops, ImageOps, ImageDraw, ImageFilter, ImageFile
from PIL.Image import Dither
from .shared import dot_clean, getImageFileName, walkLevel, walkSort, sanitizeTrace
ImageFile.LOAD_TRUNCATED_IMAGES = True
def mergeDirectoryTick(output):
if output:

View File

@@ -24,13 +24,14 @@ import numpy as np
from pathlib import Path
from functools import cached_property
import mozjpeg_lossless_optimization
from PIL import Image, ImageOps, ImageStat, ImageChops, ImageFilter, ImageDraw
from PIL import Image, ImageOps, ImageFile, ImageChops, ImageDraw
from .rainbow_artifacts_eraser import erase_rainbow_artifacts
from .page_number_crop_alg import get_bbox_crop_margin_page_number, get_bbox_crop_margin
from .inter_panel_crop_alg import crop_empty_inter_panel
AUTO_CROP_THRESHOLD = 0.015
ImageFile.LOAD_TRUNCATED_IMAGES = True
class ProfileData:

View File

@@ -1,8 +1,10 @@
from PIL import Image, ImageFilter, ImageOps
from PIL import Image, ImageFilter, ImageOps, ImageFile
import numpy as np
from typing import Literal
from .common_crop import threshold_from_power, group_close_values
ImageFile.LOAD_TRUNCATED_IMAGES = True
'''
Crops inter-panel empty spaces (ignores empty spaces near borders - for that use crop margins).

View File

@@ -1,7 +1,9 @@
from PIL import ImageOps, ImageFilter
from PIL import ImageOps, ImageFilter, ImageFile
import numpy as np
from .common_crop import threshold_from_power, group_close_values
ImageFile.LOAD_TRUNCATED_IMAGES = True
'''
Some assupmptions on the page number sizes

View File

@@ -1,5 +1,8 @@
import numpy as np
from PIL import Image
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
def fourier_transform_image(img):
"""