Package: qrImageIndexer
qrCodeImageSorterProject OutlineThis is a python module which is designed to assist in the easy capture and sorting of photos.
It aims to solve a problem I have identified where a large number of photos need to be taken
in a structured manner. While there are apps which aim to acheive this natively on device,
these can sometimes make sharing of the task difficult. They are often also not as fast as
the native camera apps, also sometimes missing some of the native post-processing on phones.This tool will allow users to produce a simple list of QR codes that can be used as indices
in the photos. The photos will then be split into folders based on the content of the QR
codes.Operational PhilosophyThe principal of this tool is to generate QR codes which can be printed and included in the photo
set being captured. Images with QR codes included will be detected and used as index photos. Any
photos found after (and including) the index photo, up to the next index photo, will be sorted
into a directory as indicated by the QR code. Photos will be processed in file name order as
this is consistent with the capture method of all phones and cameras I have personally used.All sorting is done through copying. The original files are left in-place and unmodified.QR codes may appear in the images in any order. As the directory is determined by the QR code,
it will be sorted accordingly. The same code may also appear multiple times and will simply add
the additional content to the resulting directory.Sorting ExceptionsNon-ImagesAs the tool is targetting images, any files which are not images will be copied into the
directorynon_image_files/under the target output directory.Files Before Index ImageIf there are images which appear before the first QR-containing image will be copied into
the directoryunsorted/.Example Input ImagesInstallationThe package is available on PyPi and can be installed with the following command:pip install qrImageIndexerIf you are not using Windows you will also need to install the zBar binaries (these are included
in the wheel for Windows users):https://pypi.org/project/pyzbar/InstructionsTool Command Line ArgumentsTo use the tool run the command:python -m qrImageIndexerCommand line useage is as per below:usage: qrImageIndexer [-h] [-g INPUT_TEXT_FILE OUTPUT_PDF | -s INPUT_DIR OUTPUT_DIR] [--pdf-type SORT_TYPE] [-q] [-r] [-p STRING_PREFIX] [-v]

options:
  -h, --help            show this help message and exit
  -g INPUT_TEXT_FILE OUTPUT_PDF, --generate-pdf INPUT_TEXT_FILE OUTPUT_PDF
                        Generate a PDF of QR codes from a given text file. Specify
  -s INPUT_DIR OUTPUT_DIR, --sort-photos INPUT_DIR OUTPUT_DIR
                        Sort photos based on QR codes found in photos. Once a QR code is found all photos will be sorted into the directory indicated by the code until subsequent codes found
  --pdf-type SORT_TYPE  Type of PDF to generate. Either linearly sorted or sorted to enable easy slicing of the printed pages. Accepts "linear" or "sliceable". Linear will sort down page, sliceable will sort "through" the page.
  -q, --qr-for-headings
                        Generate a QR code for each heading, not just a code for the last items in a tree.
  -r, --repeat-table-headings
                        Repeat table headings on every line
  -p STRING_PREFIX, --string-prefix STRING_PREFIX
                        Specify a prefix for use in the generated QR codes to differentiate from codes that might also end up in photos
  -v, --verbose         Turn progress text to terminal on or offGeneral usageIn general usage the user will generate QR codes from a text file. These QR codes will then be used as index cards while taking photos. Any photos
which appear subsequent to a QR code but before the next QR code will be sorted into a folder. Any photos which appear before a QR code will be sorted
into a specific folder of their own.PDF FormatFor ease of use it is recommended to use the--pdf-type sliceableoption, which will allow, when printed single-sided, for the QR codes to be easily sliced
and stacked for use in-order.File FormatExpected input file format is as a tab indented list. Each level of indentation is considered a child tested below the preceeding level. When photos are sorted
these nested elements will form the file paths.Additional file formats could easily be added
and may be a good first issue for anyone who wishes to contribute.An example input file is shown below:Line 1
    Line 1 1st indent item 1
        Line 1 2nd indent
    Line 1 1st indent item 2
Line 2
Line 3
Line 4
Line 5
Line 6In this case photos underLine 1 1st indent item 1would appear in the directoryLine 1/Line 1 1st indent item 1/and photos underLine 1 2nd indentwill appear in the directoryLine 1/Line 1 1st indent item 1/Line 1 2nd indent/.Generally it is recommended that folder structure be used to sort and plan photo capture logically. E.g. level 1 of the
structure may be particular rooms, level 2 may be objects in the room and level 3 may be specifics about the object.There is no limit on the number of levels that may be included in the document, but higher numbers will result in messier/busier output PDFs.Other Recommended OptionsOther options such as-rwhich will result in the headings from further up the tree being repeaded in the output PDF and-qwhich will generate QR codes for headings as well as the tails of the tree may both also be useful.If it is expected that other QR codes may be present, a prefix can also be added to the QR code package. This can be done with the-poption.Using the option-vfor any operations will provide verbose status output to the command line.Generating PDF DocumentAssuming that the above demo file is saved asdemo.txtthe following command would generate a PDF with repeated headings and qr codes for each line in a sliceable format, with the prefix{image}:python -m qrImageIndexer -g demo.txt demo.pdf -r -q --pdf-type sliceable -p "{image}"Sorting ImagesAfter taking photos, these images could then be sorted into a folder calledoutputs\from a folder calledinputs\as shown below:python -m qrImageIndexer -s inputs\ outputs\ -p "{image}"Future FeaturesCurrently the module is command line only. In future this will be expanded to include a GUI
which will simplify the generation of QR codes and the scanning of images for users.