Photoview 是一个开源的照片库系统,旨在提供一个简单和快速的方式来浏览目录里的海量高分辨率照片。基于Go语言编写,遵守AGPL3.0开源协议。支持人脸识别、地理位置识别,系统自动完整扫描并生成缩略图,即可快速浏览海量照片。
Photoview使用简单,支持多语言(包括中文),默认以时间线显示照片,并且会根据不同文件夹显示不同相册。可以选择以人物来分类或以地理位置来分类浏览。
功能特色:
紧密结合文件系统. 线上网站图片的展示与本地服务器上的文件目录相匹配。
用户管理. 每个用户将独立创建一个文件目录,用户只能看到用户目录下的图片。
分享功能. 相册,媒体可以分享成为公共链接,链接可选是否需要密码保护。
为摄影师量体裁衣. 支持RAW源文件格式, 以及EXIF 属性显示.
视频支持. 支持常用视频格式,视频根据网络自动优化。
面部识别. 自动侦测人面,相同的人将自动归并一组。
高效. 缩略图自动生成,全屏模式时先显示缩略图直到高分辨率图完全下载完成。
安全. 所有媒体资源以 cookie-token保护, 密码哈希保存, API 遵守 CORS政策:
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
源码:https://github.com/photoview/photoview
-----------------------------------------------------
Photo gallery for self-hosted personal servers
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 start 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
Demo site
Visit https://photos.qpqp.dk/
Username: demo Password: demo
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
- Docker
- Arch Linux Aur
- Unraid
- EmbassyOS: announcement, repo
- YunoHost
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 simple and fast to use
All of the photo galleries can do a lot of what I need, but no single one can do it all.
Set up development environment
Local setup
- Install a local mysql server, and make a new database
- Rename
/api/example.env
to.env
and update theMYSQL_URL
field - Rename
/ui/example.env
to.env
Start API server(backend)
Make sure golang is installed.
Some C libraries are needed to compile the API, see go-face requirements for more details. They can be installed as shown below:
# Ubuntu
sudo add-apt-repository ppa:strukturag/libheif
sudo add-apt-repository ppa:strukturag/libde265
sudo apt-get update
sudo apt-get install libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg-turbo8-dev libheif-dev
# Debian
sudo apt-get install libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg62-turbo-dev libheif-dev
# macOS
brew install dlib libheif
Then run the following commands:
cd ./api
go install
go run server.go
Start UI server(front end)
Make sure node is installed. In a new terminal window run the following commands:
cd ./ui
npm install
npm start
The site can now be accessed at localhost:1234. And the graphql playground at localhost:4001
from
https://github.com/photoview/photoview
--------------------------------------------------
Manual Setup
This guide explains how to build, install and configure Photoview on a fresh installation of Ubuntu 20.04 LTS
to run directly on the system without using Docker.
Preparation
Make sure you got the necessary tools and libraries in order to build and run Photoview.
# Make sure your computer is up to date
$ sudo apt update
$ sudo apt upgrade
# Install tools used in this guide
$ sudo apt install git curl wget
# Install necessary repositories
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:strukturag/libheif
$ sudo add-apt-repository ppa:strukturag/libde265
# Install dependencies required to build and run Photoview
$ sudo apt install libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg-turbo8-dev build-essential \
libdlib19 libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg-dev libheif-dev pkg-config gpg
Install Golang by following the instructions for Linux from their Download and install Go page, the steps should be something like the following.
# Download Go
$ wget https://golang.org/dl/go1.16.linux-amd64.tar.gz
# Install Go
$ sudo tar -C /usr/local -xzf go1.16.linux-amd64.tar.gz
$ rm go1.16.linux-amd64.tar.gz
# Add Go to the path of your user
$ echo 'export PATH=$PATH:/usr/local/go/bin' >> "$HOME/.bashrc" && source "$HOME/.bashrc"
# Verify that go is now installed
$ go version
# Expected output: go version go1.16 linux/amd64
Now install Node 16 and NPM if you've not done so already (it installs npm automatically)
$ curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
$ sudo apt install nodejs
Download and build Photoview
Navigate to Photoview Releases and download the source code for the latest version, extract it and open the extracted directory in the terminal.
$ cd /opt
$ git clone https://github.com/photoview/photoview.git
$ cd photoview/
Build the Web user-interface
$ cd ui/
$ npm install
$ npm run build
This builds the UI source code and saves it in the ui/build/
directory.
Build the API back-end
$ cd api/
$ go build -v -o photoview .
This builds the server executable to api/photoview
.
Copy needed files
Make a new directory and move the needed files to it.
$ cd /opt/photoview
$ mkdir app
$ cp -r ui/build/ app/ui/
$ cp api/photoview app/photoview
$ cp -r api/data/ app/data/
Setup database
It's highly recommended to configure a full database, but Sqlite is also supported though it might be substantially slower on big media libraries. If you decide to use Sqlite, you can skip this step.
If you don't already have a database you can configure one by following this guide on installing MySQL on Ubuntu 20.04.
If you've not done already, configure a new database and user to use with Photoview.
$ sudo mysql
# Create new user named 'photoview'
mysql> CREATE USER 'photoview'@'localhost' IDENTIFIED BY 'Photo_Secret#12345';
# Create new database named 'photoview'
mysql> CREATE DATABASE photoview;
# Grant user full access to the newly created database
mysql> GRANT ALL PRIVILEGES ON photoview.* TO 'photoview'@'localhost';
This will create a new user photoview
with the password Photo_Secret#12345
and a new database named photoview
.
When you're done you should have a running MySQL database with a new user identified by a username and password and an empty database.
Configure Photoview
Photoview is configured through environment variables. It will also load environment variables from a .env
file. We will use that to configure Photoview.
Copy the api/example.env
file to the output directory, and name it .env
.
$ cp api/example.env app/.env
To configure the database to use our MySQL database, edit PHOTOVIEW_MYSQL_URL
to match our database configuration. Replace user
, password
and dbname
.
PHOTOVIEW_DATABASE_DRIVER=mysql
PHOTOVIEW_MYSQL_URL=user:password@tcp(localhost)/dbname
PHOTOVIEW_SERVE_UI=1
PHOTOVIEW_PUBLIC_ENDPOINT=http://localhost:4001/
See environment variables for more details.
Install optional dependencies
Photoview can use some external programs to do more advanced things, these programs are not required to use Photoview but some functionality will only be avaliable with them installed.
RAW photo support
Photoview can use Darktable to convert RAW photos to JPEGS when scanning. To enable this install Darktable and make sure the darktable-cli
binary is in your $PATH
environment variable.
$ sudo apt install darktable
Video transcoding
Photoview can use ffmpeg
to convert video files that cannot be played directly in the browser.
$ sudo apt install ffmpeg
Exif parsing
Photoview can optionally use exiftool
to parse EXIF metadata faster and more reliably. Without it it will use its internal exif parser.
$ sudo apt install exiftool
Post installation
If you've made it this far, you should be able to start Photoview. (Skip this step if you are using the systemd
unit file.)
$ ./photoview
Once it has started it should print something like the following. (If using the systemd
unit, this message should be visible in the output of the systemctl status
command.)
Photoview UI public endpoint ready at http://localhost:4001/
Navigate to http://localhost:4001/ and you should be presented with the "Initial Setup" wizard. From here enter a new username and password. For the Photo Path
enter the filepath for your media, you can always change this later from the settings.
Next click Setup Photoview
to create the new admin user.
Now navigate to the Settings page and click on Scan All. The scanner should now begin to scan for new media.
from