This is some of the code from my raspberry pi photo-frame project that I made.  Better description coming soon.