Giter Club home page Giter Club logo

photo-gallery's Introduction

Photo Gallery

Photo Gallery is a self-hosted performant application to organize your photos. Built with speed in mind with React and Go, you can browse through your photos quick and easy.

Photo Gallery

Motivation

There are a lot of photo gallery projects out there. However they often have their own unique way of storing data so you don't really have control how it is organized, not just the photos themselves, but also like albums, favorites and other preferences alongside. All of this must be kept transparent and accessible.

Another key feature of project is its ease of use, an app that was intuitive and quick to navigate between albums and thousands of photos. And projects that have a good array of features they could be improved upon in this regard.

It was important as well supporting a wide range of data formats, including iPhone Live Photos (HEIC images and H.265 video). With so many different types of devices and formats, it can be a challenge to keep all of your photos organized in one place.

Finally, an app that is lightweight and could run on small devices like a Raspberry Pi.

To sum up, the reason for this project is to be open sourced, you owning your own data and supporting a wide range of data formats all with an easy navigation and a lightweight design.

Goals

Built around the file system: photos are loaded from albums. Data is preserved as-is in the filesystem. Changes you make later are saved as transparently as possible, like as choosing your favorites. No requirement to be tied to a database. If you decide for another solution you should own all your data.

Performant: no need for initial and regular scans. Thumbnails are used to see a large amount of photos at a time and are automatically generated on-the-fly.

Made for photography: for everyone, amateur or professional, that enjoys taking photos and revisiting precious memories captured through them.

Ease of use: navigation through albums as easy as possible

Features

First, few concepts to keep in mind about how things are organized:

  • Albums are folders in the filesystem and the images inside are the photos of the album
  • Collection is a set of albums, in other words, is the location where your collection is stored
  • Pseudo Album is special type of album, is file stored in the filesystem which contains links for the photos. This way you can organize your favorites without duplicating them

Main features:

  • Multiple collections
  • Easy navigation between albums
  • Light, Dark and System-defined themes
  • iPhone Live Photos
  • Access through WebDAV
  • Automatic transcoding on-the-fly for required formats
    • for images
    • for videos
  • Image files supported:
    • JPEG, GIF, PNG, BMP, TIFF, VP8, VP8L, WEBP, HEIF/HEIC
    • RAW (DNG, Apple ProRaw)
  • Video files supported:
    • Containers: MP4, MOV, AVI
    • Codecs: H264, H265
  • Thumbnails generation (on-the-fly or in background)
  • Pseudo albums:
    • Create
    • Save favorite photos
  • Show storage info
  • Metadata extraction from photos (EXIF)
  • Show photo location in a map
  • Organize photos:
    • Upload new photos
    • Move photos
    • Delete photos
    • Save favorites
    • Easy selection
  • Authentication
  • Photos timeline with virtual scroll
  • View all places from photos in a map
  • Search for duplicates
  • Tool for renaming files
  • Image resizing according with screen

Quick start

Using docker, run:

docker run -p 3080:3080 --name photo-gallery rigon/photo-gallery:demo

That's it, enjoy! Just open in your browser http://localhost:3080.

This image however includes a demo gallery, for your own use please use rigon/photo-gallery.

Build and Run

First, clone the project:

git clone https://github.com/rigon/photo-gallery.git
cd photo-gallery

Then, build the web interface and the server:

npm install
npm run build
npm run build-server

To start the server:

npm run server

Once started, open http://localhost:3080 to view it in your browser.

Optionally you can open http://localhost:3080/webdav in the file explorer as well.

Usage

Server help:

Usage of ./server/photo-gallery:
  -b, --[no-]cache-thumbnails   Generate missing thumbnails while scanning (default true)
  -c, --collection strings      Specify a new collection. Example name=Photos,path=/photos,thumbs=/tmp
                                List of possible options:
                                  index          Position in the collection list
                                  name           Name of the collection
                                  path           Path to load the albums from
                                  thumbs         Path to store the thumbnails
                                  db             Path to cache DB, if a filename is provided it will be located in thumbnails directory
                                  hide=false     Hide the collection from the list (does not affect webdav)
                                  rename=true    Rename files instead of overwriting them
                                  readonly=false
      --disable-scan            Disable scans on start, by default will cache photo info of new albums
      --disable-webdav          Disable WebDAV
      --full-scan               Perform a full scan on start (validates if cached data is up to date)
  -h, --host string             Specify a host (default "localhost")
  -p, --port int                Specify a port (default 3080)
  -r, --recreate-cache          Recreate cache DB, required after DB version upgrade
      --workers-info int        Number of concurrent workers to extract photos info (default 2)
      --workers-thumb int       Number of concurrent workers to generate thumbnails, by default number of CPUs

Docker

This project is distributed via docker (Photo Gallery Docker Hub page).

The following example illustrates a case where you have two folders mounted with volumes, one with the collection of photos that is read-only and a recent folder with your still unorganized photos that is writable.

docker run -d -p 3080:3080 --restart=always --name photo-gallery \
-v photo-gallery_data:/thumbs \
-v /media/data/photos/:/photos/:ro \
-v /media/data/recent/:/recent/:rw \
rigon/photo-gallery \
-c "name=Photos,path=/photos,thumbs=/thumbs" \
-c "name=Recent,path=/recent,thumbs=/thumbs"

If you prefer Docker Compose, here is the same example:

version: "3"

volumes:
  photo-gallery_data:

services:
  photo-gallery:
    image: rigon/photo-gallery
    volumes:
      - photo-gallery_data:/thumbs
      - /media/data/photos/:/photos/:ro
      - /media/data/recent/:/recent/:rw
    ports:
      - 3080:3080
    command:
      - "-cname=Photos,path=/photos,thumbs=/thumbs"
      - "-cname=Recent,path=/recent,thumbs=/thumbs"

photo-gallery_data can be safely deleted, however cached data must be regenerated.

WebDAV access

WebDAV endpoint is like http://localhost:3080/webdav and makes it very easy to access to the photo galleries in the file explorer (just past the URL in the address bar) or to upload photos directly from your phone.

For uploading from your phone, the app PhotoSync makes that task very convinent. However for WebDAV functions you have to purchase it and we do not have any partnership with them. When creating a new WebDAV configuration in PhotoSync, make sure you fill the field Directory with /webdav

Remote access is also possible by configuring Port forwarding over SSH using tools like Terminus. See How to configure Port forwarding in Terminus. For iOS is more difficult setting it up, you can find more info here and here.

Development

Build docker multi-arch

docker buildx build --push -t rigon/photo-gallery --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x .

Available Scripts

In the project directory, you can run:

  • npm start or npm run dev

    Runs the app in the development mode.
    Open http://localhost:3000 to view it in your browser.

    The page will reload when you make changes. You may also see any lint errors in the console.

  • npm run server and npm run server-dev

    Builds and runs the server.
    Open http://localhost:3080 to view it in your browser.

    The web version served is the production build obtained with npm run build

    server-dev is the same, but monitors for changes and reloads automatically

  • npm test

    Launches the test runner in the interactive watch mode.
    See the section about running tests for more information.

  • npm run build

    Builds the app for production to the build folder.
    It correctly bundles React in production mode and optimizes the build for the best performance.

    The build is minified and the filenames include the hashes.
    Your app is ready to be deployed!

    See the section about deployment for more information.

Contribute

Contributions to this project are very welcome, by reporting issues or just by sharing your support. That means the world to me!

Please help me maintaining this project, only with your support I can take the time to make it even better. Look here for more info!

photo-gallery's People

Contributors

rigon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

photo-gallery's Issues

Webdav

1.5.0 dev, 1.5.1
When using an application to transfer photos from an android phone, PhotoSync - Transfer Photos, it is impossible to connect to webdav due to the error "Expected 207 Multi-status got 200", although nominally webdab works, other applications connect normally (X-plore File manager for example).

User interface

Please tell me how to mark images for deletion or transfer to another folder? (1.5.0 dev). It would probably be convenient to implement some kind of checkbox for selecting images.

And are there any plans to optimize the interface for mobile devices? Currently, when viewing the interface on a phone, not all top line icons are displayed on the screen (theme selection, zoom)

Gallery Functions

Good day to all!
Tell me, the gallery is installed with a regular docker-compose from the project page.
Version 1.5.1, but I don't see the Delete, Upload function in the web interface.

How do I find these functions at all -
Show photo location in a map
Organize photos:
Upload new photos
Move photos
Delete photos
Easy selection
Authentication
Photos timeline with virtual scroll
View all places from photos in a map
Search for duplicates
Tool for renaming files

Or are these plans for future releases?

Docker image no work after v1

Hello, just to point out that docker versions after v1 don't work, I don't have web access, although there doesn't seem to be any errors.

2023/06/13 20:08:25 Collections: map[Photos:Photos (/photos)]
2023/06/13 20:08:25 WebDAV will be available at http://localhost:3080/webdav
2023/06/13 20:08:25 Starting server: http://localhost:3080

best regards

Sorting images by date

Images with the same date but different time zone are sorted incorrectly.
These two are sorted like this:

  1. 2023-06-17T23:25:00+03:00
  2. 2023-06-17T20:20:00Z

But is should be the other way around.

Avoid scanning same album concurrently

When an album requires scanning but there are multiple requests that album, multiple scans are spawned in the same album.

Should be a locking mechanism to prevent starting a scan if another scan is already running on the album.

Performance degradation in cache DB

Performance of saving to bbolt degrades when the DB grows in size, even when it is just updating an existing entry. This is more noticeable when updating the thumb flag.

Support albums in read-only

Folders can have a read-only flag enabled in the filesystem, so the album should be read-only as well.
Disable modify the album (upload, move, rename, delete), reflect that in the interface.

URLs not correct when navigating in lightbox

Only the photo parameter is changing when navigating through photos in lightbox. However when viewing a pseudo album, the collection and album should change as well because photos are from different locations. But changing the collection and album causes the app to load the whole album and even album list every time a navigation occurs in lightbox.

This can be solved using a manager that controls when to load things and with a global state for current location.

Not properly scanning album if has favorite photos

Albums might not be scanned properly. This happens when a partial scan is ran before scanning the full album. Partial scan happens when loading pseudo-albums, only the favorite photos are scanned. However, this will flag the album as fully scanned, skipping when running the full scan thereafter.

panic: sync: WaitGroup is reused before previous Wait has returned

panic: sync: WaitGroup is reused before previous Wait has returned

goroutine 49 [running]:
sync.(*WaitGroup).Wait(0xe585d0)
        /usr/local/go/src/sync/waitgroup.go:138 +0xc0
main.WaitBackgroundWork(0xb8?)
        /app/worker.go:68 +0x2c
main.AddThumbsBackground(0x40000e7c20, 0x4005ce6070, {0x40087f2000, 0x5023, 0x40005afe38?})
        /app/worker.go:128 +0x8c
main.(*Collection).CreateThumbnails(0x40000e7c20)
        /app/scan.go:104 +0x4dc
main.main.func1()
        /app/main.go:404 +0x154
created by main.main
        /app/main.go:391 +0x2c8

Organize photos

Organize photos in bulk:

  • Upload new photos
  • Move photos
  • Delete photos
  • Save favorites
  • Easy selection

Docker Compose

Love the look and idea behind this.

Is there a docker compose file available for this?

Saving favorites multiple times

When saving photos as favorites multiple times, the existing references doesn't get updated.
For example:

  • Save photo as favorite to pseudo-album A1
  • Save the same photo as favorite to pseudo-album A2
  • When opening A1, the photo doesn't show that is also in A2

Improve scanning process

The current scanning process is a bit clumsy.

I'm proposing a 3 tier scans. This will require an additional flag in Photo to indicate if a thumbnail was or was not generated.

  1. Quick:
    • Look for new albums
    • Cache photos info
  2. Regular (run by default):
    • Same as Quick, plus
    • Create all thumbnails for photos with the flag unset
  3. Full:
    • This will verify if all data is correct, for that we need the following
    • Create a list of all thumbnails files stored
    • Load all albums
    • Scan all files in albums
    • Cache photos info
    • Create missing thumbnails
    • After finish processing an album:
      • Load all DB entries for that album and remove those not in the scanned list
      • Remove entries of exiting photos from the list of all thumbnails
    • In the end, the remaining entries in the list of all thumbnails should be removed
    • Entries in the DB for missing albums should be removed as well

Additionally, consider as well:

  1. Creating a process to allow updating the cache in background. Benefits:
    • During the scan, do not to wait while updating the cache
    • Unify code where in some places is already updating cache in background
  2. Allow suspend scan in the middle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.