Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
Kabooshki | df3c1d5137 | |
Kabooshki | 2dce0d980e | |
Kabooshki | ee92dc4601 | |
Kabooshki | fb92d56b87 | |
Kabooshki | d2913ac173 | |
Kabooshki | fe186d6c12 |
|
@ -4,3 +4,4 @@ test.py
|
|||
test-files.tbkpf
|
||||
".DS_Store"
|
||||
.DS_Store
|
||||
compile*
|
|
@ -1 +1,3 @@
|
|||
THIS BRANCH IS OBSOLETE, IGNORE
|
||||
|
||||
a tool to look for page numbers in images and rename them accordingly
|
10
fixer.py
10
fixer.py
|
@ -22,9 +22,9 @@ for files in os.listdir(directory):
|
|||
cv2.imshow('Review', ROI)
|
||||
cv2.waitKey(1)
|
||||
manpage = input("please input the page number")
|
||||
if os.path.isfile(f'images/{manpage}.jpg') == True:
|
||||
if os.path.isfile(f'images/{manpage}-') == True:
|
||||
rng = numpy.random.default_rng().random()
|
||||
os.rename (f'images/{manpage}.jpg', f'images/{manpage}.review-{rng}.jpg')
|
||||
os.rename(f'{f}', f'images/{manpage}.jpg')
|
||||
elif os.path.isfile(f'images/{manpage}.jpg') == False:
|
||||
os.rename(f'{f}', f'images/{manpage}.jpg')
|
||||
os.rename (f'images/{manpage}-', f'images/{manpage}-.review-{rng}')
|
||||
os.rename(f'{f}', f'images/{manpage}-')
|
||||
elif os.path.isfile(f'images/{manpage}-') == False:
|
||||
os.rename(f'{f}', f'images/{manpage}-')
|
20
main.py
20
main.py
|
@ -18,23 +18,23 @@ for filename in os.listdir(directory):
|
|||
ROI = cv2.hconcat([ROI1, ROI2])
|
||||
data = pytesseract.image_to_string(ROI, lang='eng',config='--psm 7 -c tessedit_char_whitelist=0123456789i' )
|
||||
print(data)
|
||||
if os.path.isfile(f'images/{data}.jpg') == False:
|
||||
os.rename(f'{f}', f'images/{data}.jpg')
|
||||
elif os.path.isfile(f'images/{data}.jpg') == True:
|
||||
if os.path.isfile(f'images/{data}-') == False:
|
||||
os.rename(f'{f}', f'images/{data}-')
|
||||
elif os.path.isfile(f'images/{data}-') == True:
|
||||
cv2.imshow(data, ROI)
|
||||
cv2.waitKey(1)
|
||||
manpage = input("please input the number on the page (if the title is correct, enter nothing)")
|
||||
#check if the new name already exists
|
||||
if manpage == "\n":
|
||||
rng = numpy.random.default_rng().random()
|
||||
os.rename (f'images/{data}.jpg', f'images/{data}.review-{rng}.jpg')
|
||||
os.rename(f'{f}', f'images/{data}.jpg')
|
||||
os.rename (f'images/{data}-', f'images/{data}-.review-{rng}')
|
||||
os.rename(f'{f}', f'images/{data}-')
|
||||
elif manpage != "\n":
|
||||
if os.path.isfile(f'images/{manpage}.jpg') == True:
|
||||
if os.path.isfile(f'images/{manpage}-') == True:
|
||||
rng = numpy.random.default_rng().random()
|
||||
os.rename (f'images/{manpage}.jpg', f'images/{manpage}.review-{rng}.jpg')
|
||||
os.rename(f'{f}', f'images/{manpage}.jpg')
|
||||
elif os.path.isfile(f'images/{manpage}.jpg') == False:
|
||||
os.rename(f'{f}', f'images/{manpage}.jpg')
|
||||
os.rename (f'images/{manpage}-', f'images/{manpage}-.review-{rng}')
|
||||
os.rename(f'{f}', f'images/{manpage}-')
|
||||
elif os.path.isfile(f'images/{manpage}-') == False:
|
||||
os.rename(f'{f}', f'images/{manpage}-')
|
||||
cv2.destroyAllWindows()
|
||||
cv2.destroyAllWindows()
|
||||
|
|
Loading…
Reference in New Issue