Source Code

   The following ZIP file contains all the project source code.   This includes the Python source files, C source code files, batch files, and the Visual Studio 5.0 workspace files.  I would recommend reading the README.txt file for a quick overview of what the different files contain and how they are used, as well as other project notes. Download the Note Project Source Code.   You will also need to install Python, SWIG, and place PIL into a "pil" Python subdirectory in order to use this.

    When reading the source code, I would also recommend tracing the execution path that begins from the run.bat batch file.  Here's a quick outline of the execution path:

  1. run.bat:  This creates the web and print subdirectories, and deletes any files that might be in them from previous uses. It also calls Python to run the convert.py script which starts the main program, and once completed copies all output images and HTML files to the web directory, and the print output images to the print directory.
  2. convert.py:  This is the main script which creates an instance of the Note class, creates the web pages, renames and sorts the input images, and calls the appropriate Note class methods to clean the input images and save them with the appropriate file names.
  3. notes.py:  This file contains the Note class.  It calls methods from PIL to open, save, convert images, as well as retrieve and store pixel data.  It also calls our Python extension module to execute the methods to clean out the images.
  4. notemodule.h:  The header file for our Python extension module.
  5. notemodule.c:  Our Python extension module code.  This file contains the background removing algorithm, as well as several resizing algorithms.  The pixel data is first passed in from the Note class in notes.py from a call to PIL's tostring method, and then is returned from this module to the Note class for storage back to PIL using PIL's fromstring method.

    That should get you started, but I would also recommend reading up on the Python, SWIG, and PIL documentation which can be found at the Python website.

  Source Code