Skip to content

Webcam gallery with touch gestures and arrow key navigation, written in PHP

License

Notifications You must be signed in to change notification settings

cloveras/webcam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webcam.php

Generates HTML pages (examples here) for webcam images stored in a directory structure like this: YYYY/MM/DD/YYYYMMDDHHMMSS.jpg:

2023
├── 01
│   ├── 01
│   │   ├── 20230101000000.jpg
│   │   ├── 20230101001000.jpg
│   │   ├── 20230101002000.jpg
[...]
├── 12
│   │   ├── 20231231000000.jpg
│   │   ├── 20231231001000.jpg
│   │   ├── 20231231002000.jpg
[...]

Highlights

  • Finds sunrise, sunset, dawn, and dusk based on latitude and longitude.
  • Only shows images taken between dawn and dusk, handles midnight sun and polar night.
  • Navigation with touch gestures and arrow keys.
  • Shows the time (HH:MM) as a CSS overlay on thumbails when viewing a full day, month and year.
  • Data collection with Google Analytics and Microsoft Clarity

Example: Lillevik Lofoten webcam

If you like this you can buy me a coffee ☕️ (you'll be the first)

Things that should be changed if you want to use this

  • Edit copy-latest-image.sh and rename_and_make_mini_images.sh.
  • Add cron jobs for those two scripts. See crontab.txt.
  • Edit the filename in check_and_rename_files_hack() that covers for cron when it's too slow.
  • Update latitude and longitude (use Google Maps to find coordinates)
  • Verify the calculated sunrise and sunset at yr.no.
  • Update the dates in functions midnight_sun() and polar_night().
  • Change the code for Google and Analytics Microsoft Clarity.
  • Update the HTML meta tags.

For verbose feedback for debugging: $debug = 1.

Please note: The script started as a simple hack, then grew into this much larger and barely maintainable hack. It works well, but the code is not super elegant. PRs are welcome.

Got lots of images you need to sort and upload?

The Bash script webcam-image-organize-fix.sh can be a good starting point for reorganizing thousands of images into YYYY/MM/DD directories.

To Bash script util/nctpput-all-images.sh uses ncftp and can be a good starting point for mass-uploading thousands of files.

Example screenshots

Resized to fit.

A single image: https://lilleviklofoten.no/webcam/?type=one&image=20231126151113

Webcam example screenshot: Single image

One full day: https://lilleviklofoten.no/webcam/?type=day&date=20231126

Webcam example screenshot: Day

One full month: https://lilleviklofoten.no/webcam/?type=month&year=2023&month=11

Webcam example screensho: Month

About

Webcam gallery with touch gestures and arrow key navigation, written in PHP

Topics

Resources

License

Stars

Watchers

Forks