mirror of
https://github.com/ciromattia/kcc
synced 2025-12-20 13:11:47 +00:00
Detect too small input images
This commit is contained in:
@@ -964,6 +964,8 @@ def splitProcess(path, mode):
|
|||||||
|
|
||||||
|
|
||||||
def detectCorruption(tmpPath, orgPath):
|
def detectCorruption(tmpPath, orgPath):
|
||||||
|
imageNumber = 0
|
||||||
|
imageSmaller = 0
|
||||||
for root, dirs, files in walk(tmpPath, False):
|
for root, dirs, files in walk(tmpPath, False):
|
||||||
for name in files:
|
for name in files:
|
||||||
if getImageFileName(name) is not None:
|
if getImageFileName(name) is not None:
|
||||||
@@ -977,6 +979,9 @@ def detectCorruption(tmpPath, orgPath):
|
|||||||
img.verify()
|
img.verify()
|
||||||
img = Image.open(path)
|
img = Image.open(path)
|
||||||
img.load()
|
img.load()
|
||||||
|
imageNumber += 1
|
||||||
|
if options.profileData[1][0] > img.size[0] and options.profileData[1][1] > img.size[1]:
|
||||||
|
imageSmaller += 1
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
rmtree(os.path.join(tmpPath, '..', '..'), True)
|
rmtree(os.path.join(tmpPath, '..', '..'), True)
|
||||||
if 'decoder' in err and 'not available' in err:
|
if 'decoder' in err and 'not available' in err:
|
||||||
@@ -985,6 +990,13 @@ def detectCorruption(tmpPath, orgPath):
|
|||||||
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
|
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
|
||||||
else:
|
else:
|
||||||
os.remove(os.path.join(root, name))
|
os.remove(os.path.join(root, name))
|
||||||
|
if imageSmaller > imageNumber * 0.5 and not options.upscale and not options.stretch:
|
||||||
|
print("\nMore than half of images are smaller than target device resolution. "
|
||||||
|
"Consider enabling stretching or upscaling to improve readability.")
|
||||||
|
if GUI:
|
||||||
|
GUI.addMessage.emit('More than half of images are smaller than target device resolution.', 'warning', False)
|
||||||
|
GUI.addMessage.emit('Consider enabling stretching or upscaling to improve readability.', 'warning', False)
|
||||||
|
GUI.addMessage.emit('', '', False)
|
||||||
|
|
||||||
|
|
||||||
def detectMargins(path):
|
def detectMargins(path):
|
||||||
|
|||||||
Reference in New Issue
Block a user