split workflow and documentation
This commit is contained in:
parent
2d7e380476
commit
69cac0bd47
41
README.md
41
README.md
|
@ -1,13 +1,5 @@
|
|||
# ultimate-photo-digitizer
|
||||
|
||||
|
||||
## Scanner comands
|
||||
|
||||
```
|
||||
scanimage --progress --output-file 01.png --format=png --mode Color --resolution 2400 --verbose --depth 16
|
||||
```
|
||||
|
||||
|
||||
## Setup
|
||||
|
||||
```
|
||||
|
@ -16,8 +8,39 @@ pip install opencv-python-headless
|
|||
zypper install avif-tools
|
||||
|
||||
```
|
||||
## Usage
|
||||
|
||||
### Step 1: Scan analog photos
|
||||
|
||||
1. Create `scans` folder.
|
||||
2. Place four analog photos in scanner bed, align edges with scanner. But keep a margin of 1cm between photos and between the scanner.
|
||||
3. Scan the photos via `python3 ./scan_photos.py destination_dir=scans/`
|
||||
4. Repeat step 2 to 3 until all photos are scanned.
|
||||
|
||||
### Step 2: Extract the single photos from the scan
|
||||
|
||||
1. Create `tmp` folder.
|
||||
2. Extract the photos via `python3 extract_photos.py source_dir=scans/ destination_dir=tmp/`
|
||||
|
||||
### Step 3: Rotate the extracted photos
|
||||
|
||||
1. Use any image viewer, like gwenview, to rotate and save the photos if necessary.
|
||||
|
||||
### Step 4: Convert the extracted photos to AVIF
|
||||
|
||||
1. Create `photos` folder.
|
||||
2. Convert the photos via `python3 convert_photos.py source_dir=scans/ destination_dir=photos/`
|
||||
|
||||
## Sync folders between machines
|
||||
|
||||
### Push scans to server
|
||||
`rsync -Pav -e "ssh -i $HOME/.ssh/SDS" /home/hendrik/git/ultimate-photo-digitizer/scans/ hendrik@10.0.0.25:/home/hendrik/git/ultimate-photo-digitizer/scans/`
|
||||
|
||||
`rsync -Pav -e "ssh -i $HOME/.ssh/SDS" hendrik@10.0.0.25:/home/hendrik/git/ultimate-photo-digitizer/photos/ /home/hendrik/git/ultimate-photo-digitizer/photos/`
|
||||
### Pull tmp from server
|
||||
`rsync -Pav -e "ssh -i $HOME/.ssh/SDS" hendrik@10.0.0.25:/home/hendrik/git/ultimate-photo-digitizer/tmp/ /home/hendrik/git/ultimate-photo-digitizer/tmp/`
|
||||
|
||||
### Push tmp to server
|
||||
`rsync -Pav -e "ssh -i $HOME/.ssh/SDS" /home/hendrik/git/ultimate-photo-digitizer/tmp/ hendrik@10.0.0.25:/home/hendrik/git/ultimate-photo-digitizer/tmp/`
|
||||
|
||||
### Pull photos from server
|
||||
`rsync -Pav -e "ssh -i $HOME/.ssh/SDS" hendrik@10.0.0.25:/home/hendrik/git/ultimate-photo-digitizer/photos/ /home/hendrik/git/ultimate-photo-digitizer/photos/`
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
""" Author: Hendrik Schutter, mail@hendrikschutter.com
|
||||
"""
|
||||
|
||||
import cv2
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def convert_to_avif(input_file_path, output_dir_path):
|
||||
# print("input_file_path: " + str(input_file_path))
|
||||
# print("output_dir_path: " + str(output_dir_path))
|
||||
|
||||
output_file_path = os.path.join(output_dir_path,(os.path.splitext(os.path.basename(os.path.normpath(input_file_path)))[0] + ".avif"))
|
||||
|
||||
cmd_handle = subprocess.Popen(["avifenc", "--jobs", "all", input_file_path, output_file_path], stdout=subprocess.PIPE)
|
||||
cmd_handle.communicate()[0]
|
||||
if cmd_handle.returncode != 0:
|
||||
raise Exception("Unable to convert via avifenc! Return code: " + str(cmd_handle.returncode))
|
||||
|
||||
cmd_handle = subprocess.Popen(["sync",],stdout=subprocess.PIPE,)
|
||||
cmd_handle.communicate()[0]
|
||||
if cmd_handle.returncode != 0:
|
||||
raise Exception("Unable to sync! Return code: " + str(cmd_handle.returncode))
|
||||
|
||||
def main():
|
||||
print("starting ...")
|
||||
|
||||
destination_dir_path = -1
|
||||
source_dir_path = -1
|
||||
|
||||
for argument in sys.argv:
|
||||
if argument.startswith("destination_dir"):
|
||||
destination_dir_path = argument.split("=")[1]
|
||||
if argument.startswith("source_dir"):
|
||||
source_dir_path = argument.split("=")[1]
|
||||
|
||||
if (destination_dir_path == -1) or (source_dir_path == -1):
|
||||
print("Unable to parse config!")
|
||||
print("Example usage:")
|
||||
print(
|
||||
" python convert_photos.py source_dir=tmp/ destination_dir=photos/"
|
||||
)
|
||||
sys.exit(-1)
|
||||
|
||||
failed_conventions = 0
|
||||
|
||||
for path in os.listdir(source_dir_path):
|
||||
if os.path.isfile(os.path.join(source_dir_path, path)):
|
||||
print("Found photo: " + str(os.path.join(source_dir_path, path)), end=" ")
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
convert_to_avif(os.path.join(source_dir_path, path), destination_dir_path)
|
||||
print(" → Successfully converted photo to avif")
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
failed_conventions = failed_conventions + 1
|
||||
|
||||
if(failed_conventions == 0):
|
||||
print("\nConvert without error")
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("Unable to convert " + str(failed_conventions) + " photos.")
|
||||
print("\nExiting with error")
|
||||
sys.exit(-1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -96,7 +96,7 @@ def main():
|
|||
print("Unable to parse config!")
|
||||
print("Example usage:")
|
||||
print(
|
||||
" python extract_photos.py source_dir=scans/ destination_dir=photos/"
|
||||
" python extract_photos.py source_dir=scans/ destination_dir=tmp/"
|
||||
)
|
||||
sys.exit(-1)
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ def main():
|
|||
if (destination_dir_path == -1):
|
||||
print("Unable to parse config!")
|
||||
print("Example usage:")
|
||||
print(" python scan_photos.py destination_dir=scans/ ")
|
||||
print(" python scan_photos.py destination_dir=scans/")
|
||||
sys.exit(-1)
|
||||
|
||||
filename = time.strftime("%Y-%m-%d_%H-%M-%S.png")
|
||||
|
|
Loading…
Reference in New Issue