mirror of
https://github.com/ciromattia/kcc
synced 2026-09-01 00:17:05 +00:00
fix list index out of range for kfx (#1321)
This commit is contained in:
@@ -1706,27 +1706,27 @@ def makeBook(source, qtgui=None, job_progress=''):
|
|||||||
size = get_contain_resolution(imagef, (x, y))
|
size = get_contain_resolution(imagef, (x, y))
|
||||||
normalized_resolutions.append(size)
|
normalized_resolutions.append(size)
|
||||||
|
|
||||||
counter = Counter(normalized_resolutions)
|
counter = Counter(normalized_resolutions)
|
||||||
|
|
||||||
aspect_ratios = []
|
aspect_ratios = []
|
||||||
filtered_resolutions = []
|
filtered_resolutions = []
|
||||||
for w, h in normalized_resolutions:
|
for w, h in normalized_resolutions:
|
||||||
aspect_ratio = h / w
|
aspect_ratio = h / w
|
||||||
# page-like aspect ratios, could be improved
|
# page-like aspect ratios, could be improved
|
||||||
if aspect_ratio > 1.3 and aspect_ratio < 1.7:
|
if aspect_ratio > 1.3 and aspect_ratio < 1.7:
|
||||||
aspect_ratios.append(aspect_ratio)
|
aspect_ratios.append(aspect_ratio)
|
||||||
filtered_resolutions.append((w, h))
|
filtered_resolutions.append((w, h))
|
||||||
|
|
||||||
most_common_res, most_common_count = counter.most_common(1)[0]
|
most_common_res, most_common_count = counter.most_common(1)[0]
|
||||||
options.kfx_resolution = most_common_res
|
options.kfx_resolution = most_common_res
|
||||||
if most_common_count / counter.total() > .6:
|
if most_common_count / counter.total() > .6:
|
||||||
pass
|
pass
|
||||||
#elif max(aspect_ratios) - min(aspect_ratios) < .2:
|
#elif max(aspect_ratios) - min(aspect_ratios) < .2:
|
||||||
else:
|
else:
|
||||||
# get the widest resolution
|
# get the widest resolution
|
||||||
options.kfx_resolution = max(filtered_resolutions)
|
options.kfx_resolution = max(filtered_resolutions)
|
||||||
# else:
|
# else:
|
||||||
# raise UserWarning('Aspect ratio of pages too different for KFX conversion')
|
# raise UserWarning('Aspect ratio of pages too different for KFX conversion')
|
||||||
|
|
||||||
if options.noprocessing:
|
if options.noprocessing:
|
||||||
print(f"{job_progress}Do not process image, ignore any profile or processing option")
|
print(f"{job_progress}Do not process image, ignore any profile or processing option")
|
||||||
|
|||||||
Reference in New Issue
Block a user