|
@@ -1,13 +1,15 @@
|
|
#!/usr/bin/python
|
|
#!/usr/bin/python
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------------
|
|
#--------------------------------------------------------------------------------------------------------
|
|
-# This python file is processing a complete book
|
|
|
|
-# It assumes that there is a folder named 'input' that contains all input data
|
|
|
|
|
|
+# This python file is used for processing a complete book.
|
|
|
|
+# It assumes that there is a folder named 'input' that contains all input images
|
|
# The output is generated into a folder called 'output'
|
|
# The output is generated into a folder called 'output'
|
|
# A folder called 'temp' is also used for intermediate files (that can be cleaned later)
|
|
# A folder called 'temp' is also used for intermediate files (that can be cleaned later)
|
|
# In the 'input'-folder, there should only be image-files ending with a jpg-file-extension
|
|
# In the 'input'-folder, there should only be image-files ending with a jpg-file-extension
|
|
|
|
+# You also need a book_settings.py that store all book specific settings.
|
|
#
|
|
#
|
|
# To scan a book, start with all the right hand pages from the start to the end, then take all left hand pages
|
|
# To scan a book, start with all the right hand pages from the start to the end, then take all left hand pages
|
|
|
|
+# When starting over with the left hande page, its important to start with the same spread (page-pair) as the right-hand.
|
|
# The number of right/left-pages must be equal
|
|
# The number of right/left-pages must be equal
|
|
#
|
|
#
|
|
# The reference image and cover image can be taken in any order, but must be pointed out below in the 'arguments'
|
|
# The reference image and cover image can be taken in any order, but must be pointed out below in the 'arguments'
|
|
@@ -21,14 +23,9 @@ image_pre_name = 'IMG_' # The part of the filename before the numerical
|
|
image_post_name = '.JPG' # Part of the filename after the numerical part
|
|
image_post_name = '.JPG' # Part of the filename after the numerical part
|
|
numberNumericalsInName=4 # Number of numericals in file name-index. For example 4 in 0304 and 1234
|
|
numberNumericalsInName=4 # Number of numericals in file name-index. For example 4 in 0304 and 1234
|
|
|
|
|
|
-# Dynamic Input arguments. These very for every book that is scanned and for every scan
|
|
|
|
-refImg = 3 # The image used as reference image
|
|
|
|
-coverImage = 12 # Image used for cover (Will be placed 1st)
|
|
|
|
-firstLeftHandPage = 8 # The first image covering the left pages
|
|
|
|
-cropX1 = 333 # Crop coordinates of all the images
|
|
|
|
-cropY1 = 30
|
|
|
|
-cropX2 = 3342
|
|
|
|
-cropY2 = 2380
|
|
|
|
|
|
+# All the dynamic (book specific) settings are store in an external python-file.
|
|
|
|
+# This makes it easier to share this file while maintaining multiple settings-files.
|
|
|
|
+from book_settings import *
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------------
|
|
#--------------------------------------------------------------------------------------------------------
|
|
import os
|
|
import os
|
|
@@ -45,6 +42,7 @@ shutil.rmtree(opath, ignore_errors=True)
|
|
if not os.path.exists(opath): os.makedirs(opath)
|
|
if not os.path.exists(opath): os.makedirs(opath)
|
|
if not os.path.exists(tpath): os.makedirs(tpath)
|
|
if not os.path.exists(tpath): os.makedirs(tpath)
|
|
|
|
|
|
|
|
+# Check that there is an input folder
|
|
if not os.path.exists(ipath):
|
|
if not os.path.exists(ipath):
|
|
print('ERROR: No input folder !')
|
|
print('ERROR: No input folder !')
|
|
exit()
|
|
exit()
|