ProductPromotion
Logo

Open.Source

made by https://0x3d.site

GitHub - photoview/photoview: Photo gallery for self-hosted personal servers
Photo gallery for self-hosted personal servers. Contribute to photoview/photoview development by creating an account on GitHub.
Visit Site

GitHub - photoview/photoview: Photo gallery for self-hosted personal servers

GitHub - photoview/photoview: Photo gallery for self-hosted personal servers

License GitHub contributors Docker Pulls Docker builds codecov

screenshot

Photoview is a simple and user-friendly photo gallery that's made for photographers and aims to provide an easy and fast way to navigate directories, with thousands of high-resolution photos.

You configure Photoview to look for photos and videos within a directory on your file system. The scanner automatically picks up your media and starts to generate thumbnail images to make browsing super fast.

When your media has been scanned, they show up on the website, organised in the same way as on the filesystem.

If you have questions regarding setup or development, feel free to join the Discord server https://discord.gg/jQ392948u9

ATTENTION to Docker users !!!

We migrated to the new Docker registry https://hub.docker.com/r/photoview/photoview and all new images for the master tag, as well as future releases are going to be published there instead of the previously used registry. Old images will be still accessible in the old registry https://hub.docker.com/r/viktorstrate/photoview, so if you want to use 1 of those old images, you need to revert back to the old registry.

Please update your docker-compose.yml file to use the new registry for the photoview image, as shown in the corresponding example of the compose file: https://github.com/photoview/photoview/tree/master/docker-compose%20example

Demo site

Visit https://photos.qpqp.dk/

Username: demo

Password: demo

Contents

Main features

  • Closely tied to the file system. The website presents the images found on the local filesystem of the server; directories are mapped to albums.
  • User management. Each user is created along with a path on the local filesystem, photos within that path can be accessed by that user.
  • Sharing. Albums, as well as individual media, can easily be shared with a public link, the link can optionally be password protected.
  • Made for photography. Photoview is built with photographers in mind, and thus supports RAW file formats, and EXIF parsing.
  • Video support. Many common video formats are supported. Videos will automatically be optimized for web.
  • Face recognition. Faces will automatically be detected in photos, and photos of the same person will be grouped together.
  • Performant. Thumbnails are automatically generated and photos first load when they are visible on the screen. In full screen, thumbnails are displayed until the high-resolution image has been fully loaded.
  • Secure. All media resources are protected with a cookie-token, all passwords are properly hashed, and the API uses a strict CORS policy.

Supported platforms

Why yet another self-hosted photo gallery

There exists a lot of open-source self-hosted photo galleries already. Here are some, just to mention a few.

So why another one? I love taking photos, and I store all of them on my local fileserver. This is great because I can organize my photos directly on the filesystem, so it's easy to move them or take backups. I want to be able to control where and how the photos are stored.

The problem is, however, that RAW images are extremely tedious to navigate from a fileserver, even over the local network.

My server holds a lot of old family pictures that I would like my family to have access to as well. And some of the pictures I would like to easily be able to share with other people without the hassle of them having to make an account first.

Thus, I need a solution that can do the following:

  • A scan-based approach that automatically organises my photos
  • Support RAW and EXIF parsing
  • Have support for multiple users and ways to share albums and photos also publicly
  • Be straightforward and fast to use

All the photo galleries can do a lot of what I need, but no single one can do it all.

Getting started — Setup with Docker

This section describes how to get Photoview up and running on your server with Docker. Make sure you have Docker and docker-compose installed and running on your server. make should be installed as well if you'd like to use provided Makefile, which is optional (see step 4 for more details). 7zz should be installed in case, you'd like to use it in scope of the backup scenario instead of the default .tar.xz format. Read the comment in the Makefile, located on top of the backup section for more details.

  1. Download the content of the docker-compose example folder to the folder on your server, where you expect to host the Photoview internal data (database and cache files).

    Please note that this folder contains 2 versions of the docker-compose file:

    • docker-compose.example.yml - the fully-functional and recommended for the most cases config
    • docker-compose.minimal.example.yml - the minimal and simple config for those, who find the previous one too complex and difficult to understand and manage

    When downloading files, you need to choose only one of them.

  2. Rename downloaded files and remove the example from their names (so, you need to have .env, docker-compose.yml, and Makefile files). If you choose the docker-compose.minimal.example.yml on previous step, make sure to rename it to the docker-compose.yml.

  3. Open these files in a text editor and read them. Modify where needed according to the documentation comments to properly match your setup. There are comments of 2 types: those, starting with ##, are explanations and examples, which should not be uncommented; those, starting with #, are optional or alternative configuration parts, which might be uncommented in certain circumstances, described in corresponding explanations. It is better to go through the files in the next order: .env, docker-compose.yml, and Makefile.

If your PGSQL_PASSWORD or MARIADB_PASSWORD contain special characters (e.g. @), make sure to URL-encode them.

  1. Make sure that your media library's root folder and all the files and subfolders are readable and searchable by other users: run the next command (or corresponding sequence of commands from the Makefile):

    make readable
    

    If command(s) return Permission denied error, run them under the user, owning corresponding files and folders. Alternatively, run them adding sudo before the command: this will switch the execution context to root user and ask for the root password. You have to have permission to run sudo in the system.

    If you don't want to give required permissions to others group for your files, alternatively, you can:

    • create a group on your host with GID=999 and make all the files and folders inside volumes of the photoview service being owned by this group; then set the appropriate permissions to the group section.
    • create on your host a group with GID=999 and a user in this group with UID=999; then change the ownership of all the files and folders inside volumes of the photoview service to this user; then set the appropriate permissions to the user section.

    If you configured other mounts with media files from other locations on the host (like HOST_PHOTOVIEW_MEDIA_FAMILY or anything else), you need to run the same commands, as in the Makefile readable target, for each media root folder on your host manually: copy each command to your shell and replace the variable with the absolute path to an additional media root folder without the trailing /. Run both commands for each additional root folder.

  2. In case, you don't have make installed in your system or don't want to use it for the Photoview management activities, you could use the same commands from the Makefile and run them in your shell directly, or create your own scripts. Make sure to apply or replace the variables from your .env first in this case. Makefile is provided just for your convenience and simplicity, but is optional.

  3. Start the server by running the following command (or corresponding sequence of commands from the Makefile):

    make all
    

If the endpoint or the port hasn't been changed in the docker-compose.yml file, Photoview can now be accessed at http://localhost:8000

Initial Setup

If everything is set up correctly, you should be presented with an initial setup wizard when accessing the website the first time.

Initial setup

Enter a new username and password.

For the photo path, enter the path inside the docker container where your photos are located. This can be set from the docker-compose.yml file under photoview -> volumes. The default location is /photos.

A new admin user will be created, with access to the photos located at the path provided under the initial setup.

The photos will have to be scanned before they show up, you can start a scan manually, by navigating to Settings and clicking on Scan All

Advanced setup

We suggest securing the Photoview instance before exposing it outside your local network: even while it provides read-only access to your media gallery and has basic user authentication functionality, it is not enough to protect your private media from malicious actors on the Internet.

Possible ways of securing a self-hosted service might be (but not limited to):

  1. Configure a Firewall on your local network's gateway and allow only the intended type of incoming traffic to pass.
  2. Use VPN to provide external access to local services.
  3. Setting up a Reverse proxy in front of the service and forwarding all the traffic through it, exposing HTTPS port with strong certificate and cipher suites to the Internet. This could be one of the next products or something else that you prefer:
  4. Configure an external Multi-Factor Authentication service to manage authentication for your service (part of Cloudflare services, but you can choose anything else).
  5. Configure Web Application Firewall to protect from common web exploits like SQL injection, cross-site scripting, and cross-site forgery requests (part of Cloudflare services, but you can choose anything else).
  6. Use Content Delivery Network as an additional level of DDoS prevention: it can securely cache your media and let it be accessible from a wide list of servers on the Internet (part of Cloudflare services, but you can choose anything else).
  7. Configure a Rate Limit of allowed number of requests from a user during specified time range to protect against DDoS attacks.
  8. Set up an Intrusion Detection/Prevention System to monitor network traffic for suspicious activity and issue alerts when such activity is discovered.

Setting up and configuring of all these protections depends on and requires a lot of info about your local network and self-hosted services. Based on this info, the configuration flow and resulting services architecture might differ a lot between cases. That is why in the scope of this project, we can only provide you with this high-level list of possible ways of webservice protection. You'll need to investigate them, find the best combination and configuration for your case, and take responsibility to configure everything in the correct and consistent way. We cannot provide you support for such highly secured setups, as a lot of things might work differently because of security limitations.

Hardware Acceleration

It is possible to run the FFmpeg with a codec supproting the hardware acceleration, by defining PHOTOVIEW_VIDEO_HARDWARE_ACCELERATION. The value should be one of qsv, vaapi, nvenc.

We only verified the hardware acceleration with qsv on an Intel chip. To let it work, it must map /dev/dri devices and set a ENV PHOTOVIEW_VIDEO_HARDWARE_ACCELERATION=qsv. See [docker-compose.example.yml](./docker-compose example/docker-compose.example.yml).

If you verify other hardware accelerations working well, let us know.

Contributing

🎉 First off, thanks for your interest in contribution! 🎉

This project is a result of hard work, and it's great to see you interested in contributing. Contributions are not just about code — you can help in many ways!

Before you start, please take a moment to read our Contributing guide. It includes information on our code of conduct, the process for submitting pull requests, and more.

Remember, every contribution counts. Let's make this project better together! 💪

Set up Docker development environment

Docker development environment is easy to set up. It only requires Docker and Docker Compose Plugin locally. All dependencies are installed in a container but not in the host.

It also has some shortcomings. In macOS, Docker is running in a Linux VM. The fs notification doesn't work well in this case. You can't use reflex or nodemon to relaunch servers when code changes. The compiler runs pretty slow too.

We recommend to use Docker development environment. If Docker environment doesn't work well, like on macOS, please use local development environment.

Start API and UI server with Docker Compose

It may take a long time to build dependencies when launching servers first time.

$ docker compose -f dev-compose.yaml build # Build images for development
$ docker compose -f dev-compose.yaml up # Launch API and UI servers

The graphql playground can now be accessed at localhost:4001. The site can now be accessed at localhost:1234. Both servers will be relaunched after the code is changed.

By default, it uses sqlite3 as database. To run servers with other database, please update PHOTOVIEW_DATABASE_DRIVER value in dev-compose.yaml file and run:

$ docker compose -f dev-compose.yaml --profile mysql up # Run with mysql database
or
$ docker compose -f dev-compose.yaml --profile postgres up # Run with postgresql database

Start API server with Docker

If you don't want to depend on Docker Compose but only Docker, you can launch server as below.

It may take a long time to build dependencies when launching servers first time.

$ docker build --target api -t photoview/api . # Build image for development
$ docker run --rm -it -v `pwd`:/app --network host --env-file api/example.env photoview/api \
    reflex -g '*.go' -s -- go run . # Monitor source code and (re)launch API server

The graphql playground can now be accessed at localhost:4001.

[!NOTE] The server runs on the host network as --network host flag. It's easy to communicate between API server and UI server. If you don't want to do that, please check Docker Network to create a new network to run servers.

Start UI server with Docker

It may take a long time to build dependencies when launching servers first time.

$ docker build --target ui -t photoview/ui . # Build image for development
$ docker run --rm -it -v `pwd`:/app --network host --env-file ui/example.env photoview/ui \
    npm install # Install dependencies
$ docker run --rm -it -v `pwd`:/app --network host --env-file ui/example.env photoview/ui \
    npm run mon # Monitor source code and (re)launch UI server

The site can now be accessed at localhost:1234.

[!NOTE] The server runs on the host network as --network host flag. It's easy to communicate between API server and UI server. If you don't want to do that, please check Docker Network to create a new network to run servers.

Set up local development environment

In Linux, we recommend to use Docker Compose or Docker as a local development environment.

We can't keep verifying below commands on each environment. People may need to solve dependencies by their own.

Install dependencies

  • API
    • Required packages:
      • golang >= 1.22
      • g++
      • libc-dev
      • libheif >= 1.15.1
      • go-face Requirements
        • dlib
        • libjpeg
        • libblas
        • libcblas, recommended using libatlas-base in Debian.
        • liblapack
    • Optional tools during developing:
      • reflex: a source code monitoring tool, which automatically rebuilds and restarts the server, running from the code in development.
      • sqlite: the SQLite DBMS, useful to interact with Photoview's SQLite DB directly if you use it in your development environment.
  • UI
    • Required packages:
      • node = 18

In Debian/Ubuntu, install dependencies:

$ sudo apt update # Update the package list
$ sudo apt install golang g++ libc-dev libheif-dev libdlib-dev libjpeg-dev libblas-dev libatlas-base-dev liblapack-dev # For API requirement
$ sudo apt install reflex sqlite3 # For API optional tools

In macOS, install dependencies:

$ brew update # Update the package list
$ brew install golang gcc pkg-config libheif dlib jpeg # For API
$ brew install reflex sqlite3 # For API optional tools

Please follow the package manager guidance if you don't use apt or homebrew.

For node, recommend to use nvm. Follow Installing and Updating to install nvm locally, then:

$ nvm install 18
$ nvm use 18

You can install node with other package manager if you like.

Local setup

  1. Rename /api/example.env to .env
  • Update PHOTOVIEW_SQLITE_PATH if you don't want to put sqlite file under /api
  • To set a different DBMS driver
    • Comment the SQLite path variable
    • Update PHOTOVIEW_DATABASE_DRIVER with your driver
    • Uncomment the corresponding connection string variable for the new driver

    If your PGSQL_PASSWORD or MARIADB_PASSWORD contain special characters (e.g. @), make sure to URL-encode them.

  • Optional: modify other variables if needed according to the inline comments
  1. Rename /ui/example.env to .env

Start API server

Then run the following commands:

# Optional: Set the compiler environment in Debian/Ubuntu
$ source ./scripts/set_compiler_env.sh
# Set the compiler environment with `homebrew`
$ export CPLUS_INCLUDE_PATH="$(brew --prefix)/opt/jpeg/include:$(brew --prefix)/opt/dlib/include"
$ export LD_LIBRARY_PATH="$(brew --prefix)/opt/jpeg/lib:$(brew --prefix)/opt/dlib/lib"
$ export LIBRARY_PATH="$(brew --prefix)/opt/jpeg/lib:$(brew --prefix)/opt/dlib/lib"
# Start API server
$ cd ./api
$ go run .

If you want to recompile the server automatically when code changes:

# Start API server
$ cd ./api
$ reflex -g '*.go' -s -- go run .

The graphql playground can now be accessed at localhost:4001.

Start UI server

In a new terminal window run the following commands:

cd ./ui
npm install
npm start

If you want to recompile the server automatically when code changes:

$ cd ./ui
$ npm run mon

The site can now be accessed at localhost:1234.

Sponsors

Articles
to learn more about the open-source concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Open-Source.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory