MyPhotoShare is a static media gallery website generator (GPLv3 license), from a directory tree containing photos and videos. So you take this big directory where you've been accumulating all these photos or videos for so many years, you run MyPhotoShare's indexer pointing it to that directory, and it builds you a static website that you can show off your pictures to the rest of the universe…
But beware, static website does not mean limited functions! Indeed, MyPhotoShare offers several navigation or search functions for your media, by keyword or by date, by geographical location on a map. Metadata associated with media, either in JPEG images or in external album.ini
files, makes it easier to classify or display descriptions. Finally, extensions based on neural networks make it possible to add the automatic identification of people or scenes.
New functions are added very frequently to MyPhotoShare which is currently at version 5.3.10. Although MyPhotoShare is little known, the main developer is very dynamic and quickly evolves the application or fixes bugs that are reported to him. We are going to introduce you what makes MyPhotoShare different from other gallery apps.
Probably like everyone who has a digital camera or a smartphone, you have accumulated an immeasurable number of photos over time. Maybe you've sorted through those photos that sit in many directories, and now you want to share them, on the web, with your friends or family. But you want to keep control over these photos and prevent them from being used by Web giants for not always humanitarian purposes. In short, you want to present them in a web gallery, perhaps on your small server at home or at a web host.
Enter MyPhotoShare… This application will allow you to browse the tree structure of photo directories to generate a media gallery website. The particularity of MyPhotoShare is that the gallery website is static, that is, it is not an application that runs on the web server and it does not use a database . The media indexing program (the scanner
of MyPhotoShare) builds all the files for the display of the website in advance, which will be laid out in the visitor's web browser. You can think of this media indexing operation as preparing a large cache on the web server's disk. The web server is therefore reduced to retrieving and sending files, something it knows how to do efficiently, rather than executing PHP or other code to find the image to display and size it for display...
As we have just seen, the first advantage is in terms of performance. Since all the elements that make up the HTML page that will be displayed in the web browser are already ready, the work of the web server is limited to fetching them from disk and sending them to the visitor's browser. For example, this feature allows me to host MyPhotoShare on a Chromebook that does not shine with its power.
On the other hand, the media, photos and videos, are rarely modified. So if a photo is resized in advance for display on a mobile phone, the result can be reused by all visitors using their smart phone. Just keep this file in a cache. This is what the MyPhotoShare scanner
does. It prepares all files, for all scenarios. And since there are usually few changes from run to run, perhaps adding a few photos, this is done quickly, as the scanner
only considers new or changed media files. By performing this content preparation operation at a time when the server is less busy, its power is reserved for busy times. Overall, the web server can accept more concurrent sessions, because it does not execute dynamic code, unlike a gallery written in PHP for example.
Another consequence of doing this is to improve the overall security of the web server. Indeed, the scanner
can carry out its work with a user account which makes it possible to write on the disc whereas the user account of the Web server can be limited only to the reading of these files. By reducing the attack perimeter of the Web server and by limiting the tasks it performs, we ensure good security. It will be difficult for a hacker to disrupt the functioning of the media gallery.
If a static website is both powerful and secure, what are its disadvantages? The main one is that it is not as dynamic as a web application which could use the full capacity of the server, with a dynamic database and calculations. You can't have butter and butter's money! But in the case of a media gallery, these dynamic possibilities are not necessary. MyPhotoShare also offers advanced navigation or search functions without requiring dynamic calculations from the Web server.
Another disadvantage is that the website user cannot push information to the server. Indeed, as we said, this one is read-only. It is therefore impossible to keep the results of a Web form there, or even to process it, because it does not use a language such as PHP or Python, or to keep information about the Internet user. You were looking for a gallery that offers you control of your files, and in addition you guarantee your visitors that they will not leave traces!
As I said before, the scanner
is a program for indexing the photo and video files (the media) contained in the directories (the albums). It creates JSON files which are the equivalent of a database's index files. When an Internet user consults a MyPhotoShare site, his browser will load the home page of the gallery. The JavaScript contained in this page will load, depending on the actions of the user, the corresponding JSON files as well as the images necessary to render the page. For this to work, the scanner
must have generated all the JSON files for all the possible actions in advance!
And yes, we can see this way of proceeding as an advantage and a disadvantage. The static site must prepare the rendering of the pages in advance, independently of the requests of the different visitors. It is true that it is possible that some pages generated in advance are never displayed and that the indexer has worked unnecessarily, but if the site is popular the probability that this work is useless decreases. On the contrary, a dynamic server would recreate the content of a page each time for any new visitor. The static website therefore optimizes the effort in the short term (responding to an HTTP request) and in the long term (preparing the work and keeping it in a permanent cache). And as I said before, the frequency of content changes can work equally well or against a static website, but in the case of a media gallery, it's often an advantage, because the changes are infrequent.
If you want to see what MyPhotoShare looks like, there are some demo sites in the links of the dispatch.
The main demo site, in English, has been built to test the development version and present certain functions of MyPhotoShare. In particular, you can use the pwd password to view and navigate protected content.
A version with identical media content, but in French, is hosted on my small server at home. Just like the main site, the pwd password will reveal a protected album.
MyPhotoShare has the classic functions that one would expect from a modern gallery, such as displaying media on a computer as well as a tablet or mobile phone. Instead, I'm going to introduce features that you wouldn't expect to find on a static website.
Metadata adds information to stored photos and videos. Some technical metadata is automatically injected by the camera into the EXIF, IPTC or XMP areas of JPEG files, such as image resolution, lens aperture, date of capture or GPS coordinates of the shooting. The user can add other descriptive metadata by giving a meaningful name to the JPEG file, or by editing the EXIF zones.
MyPhotoShare will extract metadata from media files, but will also allow the user to set metadata in album.ini
files which are placed in the photo and video directories. These album.ini
files allow you to define new descriptive or technical metadata, without touching the original files. Indeed, the metadata coming from the album.ini
have priority over those present in the JPEG. If, for example, I digitize a slide taken in 1978 in 2021, I can specify in the album.ini
file the real date of the shot. I can also add a description with HTML formatting which MyPhotoShare may or may not display, depending on the wishes of the website visitor.
Apart from not having to modify the original media files, the advantage of the album.ini
metadata files is that they are associated with the directories (the albums) and therefore that we can transfer them when we copy the directory . In addition, they are editable with a simple text editor and can therefore be enriched easily without requiring any other software or image editor. Finally, they open the door to automatically adding information from other tools, without risking losing the original photos, which I will discuss a little later.
In the future, I hope album.ini
files will change the way the scanner
works based on the information they contain. Currently the indexer settings are defined in the configuration file, by default in /etc/myphotoshare/myphotoshare.conf
and these settings apply for the whole album tree. One can imagine that it will be possible to modify these parameters locally, within the framework of a directory containing an album.ini
file, in order to have a different web page color or to automatically display the descriptions…
MyPhotoShare uses metadata in many functions:
The media are arranged in directories on the server disk. Naturally, MyPhotoShare translates these directories into albums and offers them to be displayed. But it adds virtual directories that enrich photo browsing. Thus, MyPhotoShare offers a display of media in albums sorted by date: year, month and day. It is also possible to display the media by in albums divided by geographical location: country, region or province, city.
On this last point, navigation by map, accessible by clicking on the pin icon, makes it possible to display the photos according to the places.
Search results are also grouped into a virtual album. And it is also possible to combine several albums. For example, select a region on the map to then display the photos corresponding to the results of a search by keyword.
Finding a photo among all those accumulated over the years is often a difficult task. MyPhotoShare's time navigation will allow you to find Cousin Emile's wedding photo, but you still have to remember the wedding date! Fortunately, digital cameras automatically include the shooting date in the JPEG files... Similarly, we can try to find Emile's photo by browsing by geographical location, if the mobile phone has recorded the GPS coordinates in the metadata. , or if these were added later.
If the owner has enriched his media collection with descriptive metadata, at least by naming the media files or directories, ideally by filling in the EXIF metadata fields or those of the album.ini
, MyPhotoShare will use this information to allow text searches by keyword.
It may seem surprising that a static website offers search options such as partial search in words, or without taking emphasis into account. MyPhotoShare also supports refining searches by combining them. If with that we don't find Émile in his three-piece suit!
Each visitor to the gallery can customize the display according to their taste. MyPhotoShare has basic options:
The user's choices are stored in a cookie that will allow him to find his preferences during subsequent visits.
Of course, the website owner will set global display options in the myphotoshare.conf
configuration file, such as page background color, default display language or thumbnail size, etc.
For the moment, the display is relatively fixed: a MyPhotoShare gallery will not be very different from another MyPhotoShare gallery. There are either albums, a media contact sheet, or a main photo and a ribbon. I would like MyPhotoShare to evolve, in the future, to be able to organize the display by album, so that these are the visual support of a story...
You have finally found the photos of cousin Emile! All that remains is to make a selection where Uncle Robert appears and send them to him. MyPhotoShare allows you to select media. Did you notice the checkbox in the media thumbnails, bottom left corner, of previous screenshots? Just click on this box to add the corresponding media to the selection. Or select all displayed media using the menu. Or select all the results of a search…
Once all the media have been added to your selection, MyPhotoShare allows you to download them. The application builds a Zip file which you can save on your computer. Before receiving the Zip file, you can select the file types (photos and/or videos) and whether the selection should include the sub-albums.
But maybe you prefer to share a link in an email or on a social platform? The sharing icons, displayed on the left edge of the gallery, do just that. If you click on the envelope, your email client builds an email with the link to the current page. Similarly, by clicking on the [f], you can share the media of the current page on Facebook. If it is an album, MyPhotoShare builds a mosaic thumbnail with the content.
These social sharing features gave the gallery its name …Share. They are the only ones requiring the use of PHP by the Web server, and which cause the home page to be index.php
. If these functions are not useful to you, you can use the static version index.html
.
Social sharing sites, displayed by their icon, can be configured in the site's myphotoshare.conf
configuration file. Those displayed in the screenshots are the default ones. It is sometimes necessary to publish a few photos on the big social sites to remind Internet users that the Web exists outside of Facebook…
Basically, if OpenCV is installed on the server, then the scanner
indexing program will use it to determine if a face appears in a photo and will arrange to center the face when preparing the thumbnail. It's more practical to have thumbnails where you immediately recognize who is there!
I developed two extensions to add advanced functions to MyPhotoShare. The first is face recognition. From directories containing photos and album.ini
files that identify people in these photos, the Python script mps_autofaces
will learn to recognize these people using a neural network. Then it will go back through the tree structure of albums and photos, and modify the metadata of the album.ini
files to add the names of the people who appear in the photos.
The results produced by this extension are stunning. I sometimes have trouble recognizing a person in a photo, but mps_autofaces
is able to identify it if it has already learned it. As explained on the Gitlab page of the project in English, I use a directory containing photos of portraits or identity photos, so that learning the neural network is facilitated. But even with a single photo of an individual, this extension is able to recognize that person in varying contexts or at different ages.
Of course, large photo hosting sites or social networks have similar functions, probably more powerful than mps_autofaces
because these must be able to recognize people you don't even know! But I prefer to keep control of my photos and the use of my personal image.
The second extension tackles the recognition of scenes and objects in photos. The principle is the same as for the recognition of individuals: the program trains a network of neurons to recognize objects and situations from a base of learning images. I am using Visual Genome and MS COCO image collections for this operation. These image databases together contain more than 400,000 annotated sample images describing the scenes and objects present. This learning game is enhanced by various techniques, for example, by applying a mirror effect to the images to double the number of learning examples. As the learning phase is very long, multiple backups of the neural network are performed.
Once the neural network provides good recognition results on the test images, it can apply its knowledge on the content of MyPhotoShare albums with the mps_autoscenes
command. This script also modifies the album.ini
files to add the labels corresponding to the objects or scenes recognized automatically.
As MyPhotoShare offers a user interface in several languages (currently French, Italian, English and Spanish), it was necessary that the automatic labels of objects and scenes be in the language of the website. This is made possible by the use of the WordNet lexical database, which allows concepts to be translated from English, which was used for the annotations, into the language of the site.
Unfortunately, even with hundreds of thousands of examples, and several days of learning on my personal computers, the results are not at the same level as face recognition. mps_autoscenes
is able to recognize many objects (flowers, animals, vehicles or people, etc.) in my photos. He does not make an error of interpretation in approximately 50% of the cases, which means that in the remaining 50%, he will confuse the portrait of cousin Félicien with a coffee pot! I do not have the necessary means to improve these results at the moment. And since MyPhotoShare does not yet have a search function with weighting in tags, I have to manually review the autotags added by mps_autoscenes
.
MyPhotoShare has many other functions on which I will not expand. See the full list on the project's Gitlab site. We will note :
This is all well and good, but will it work on my machine?
If it's a computer running Debian or Ubuntu, the easiest way is to use a package from a recent release that will check the dependencies. If the latest version of MyPhotoShare is not yet available packaged, build the English package yourself.
Otherwise, if your computer runs on Linux or a similar system, the installation procedure in English will guide you step-by-step to install the necessary software and modules and will even tell you how to configure your Web server.
We have never tried installing MyPhotoShare on a Windows computer. If you try the experiment, share your results! MyPhotoShare is programmed mainly in Python, so technically it shouldn't be impossible...
MyPhotoShare has chosen to generate a static website rather than using server code in PHP or Python. This decision, made many years ago by the original author, turned out to be a good choice. Thus the gallery is able to operate even on very small servers that save on electrical power. It's to you, Raspberry v1 or Cubox-i owners who sleep unused on shelves, to whom I speak!
Here are some figures taken from tests by Paolo Benvenuto, the main developer who maintains and improves MyPhotoShare.
For comparison, on a desktop PC, with media albums on a NAS partition:
The conversion of videos takes much longer than that of photos, especially since their duration is long.
Indexing 45,000 media requires 1.5GB/2.1GB of RAM/virtual memory.
The JavaScript code is optimized and the gallery handles 40,000 media easily.
However, if an album contains more than 1000 photos, some display delays are to be expected. Despite everything, the gallery remains usable.
Of course, performance comes at the cost of disk space used by the cache. We tried to keep it within reason. The ratio of the cache size to the size of the original albums depends on many factors such as the number of intermediate frame sizes you want (see the reduced_sizes
option in the config file) and the video transcoding options (see video_preset
for example), or of course the duration of the videos. It should be noted that these figures were obtained while the scanner
was configured to create three images of different sizes, whereas the current default configuration is limited to two images.
Site | Number of media | Size of albums | Cache size | Cache-to-album ratio |
---|---|---|---|---|
AlternaTV Demo | 95 pictures | 675 MB | 116 MB | 17% |
Production site #1 | 14k media including 20 videos | 95 GB | 25 GB | 26% |
Production Site #2 | 20k media including 439 videos | 92 GB | 66 GB | 77% |
Production Site #3 | 26k media including 430 videos | 232 GB | 82 GB | 35% |
MyPhotoShare is a branch of PhotoFloat, gallery developed by Jason A. Donenfeld, around 2016, when its author stopped developing it. The branch was enriched by Jerome Charaoui to support the videos, with contributions from Paolo Benvenuto and Pierre Métras. Paolo is now the main developer, enriching it with new functions over the versions.
There is no shortage of ideas to improve the software. It is more the resources and the time to implement them that are lacking. If you are looking for an open source project to fill a few evenings, do not hesitate to indicate your interest on the Gitlab of the project or in the comments of the dispatch. Here are some topics from my suggestion box:
The future of MyPhotoShare is therefore in front of us, as long as we do not turn around as Pierre Dac said. As this gallery is open source under the GPLv3 license, you too can contribute. A first step would be to try it out and share your photos on the web.
Medical deserts, public services: what assessment of Macron on rurality?
The best phones in 2021 for photos and video
What is the best Oppo smartphone to choose?
What is the best Xiaomi smartphone?