Hello there,
I just started to migrate my Synolog PhotoStation to Piwigo. I am using physical albums, by smlinking the ./galleries/ folder to my NAS:/photo folder.
It works so far and I am totally happy how fast piwigo is instead of DS Photo.
But, I don't like how the uploads are handled. Is it possible to configure piwigo to use physical albums, especially when creating a new sub album in a gallery, that is a physical album or upload new photos (using the app or the web upload) in a physical album?
I would prefer to handle all albums as physical albums, is there some way to do that?
Thanks,
QKnows
Offline
AFAIK web upload can't be used for physical folders/images, you'd have to use FTP or any other means (rsync, ...) to create subdirectories under galleries/ and place photos there and then sync in Piwigo. You can also use [extension by plg] Piwigo Import Tree Perl script to upload/sync entire directory trees.
Offline
I use all physical albums and don't use the upload feature. I copy the photos into the appropriate folders on the NAS and then synchronize.
Offline
Thanks for the fast reply.
Anyway - that are bad news. Due to the missing possibility to handle all my uploads as physical albums make this app not usable for me...
I would appreciate a feature that make it possible to handle all uploads as physical album!
Offline
I don't get why someone using a NAS would need a web upload to physical folders but ¯\_(ツ)_/¯
Offline
Use-Case:
I want to replace DS-Photo with another solution, all photos/albums are stored folder based.
~10 users will upload their photos to the Gallery, also mobile-sync will be used
Not IT-people have to upload the photos to the correct folder, easiest way - use web-upload (or the piwigo app)
--> Upload from Piwigo app works like web-upload, right?
With physical albums the photos for each user are separately stored (permissions using i.e smb)
Should the time will come and I have to replace piwigo, I have a structured folder, with a lot of subfolders for each user, not one large folder with "who knows who upload what, without permissions and structure" just on large "blob"
It's easier to migrate to another app with physical albums.
My use-case seems not covered by piwigo. It's a nice app, but sadly not for my usage, or I might not understand how to use piwigo correct....
Thanks for the fast replay and help
Last edited by QKnows (2021-09-20 15:51:27)
Offline
There are FTP clients with GUI (for example FileZilla or WinSCP) so anyone who's able to use a file manager will also be able to upload images to their designated folder (if it's all about having them nicely separated and permission management).
Offline
Thanks for your idea, I will check out some apps for Android and iOS.
Some people who are really not IT affine would like to use it, too. So I have to explain and teach them how to use two apps. I will think about it.
Offline
I'm in this same situation with my spouse who isn't very technical. My phone syncs to nextcloud which copies my photos to my physical symlink NAS albums which I create virtual albums from. I want my wife to upload her pictures through the app but that means all her photos are stored in uploads and I can't find all the pictures organized by year/month in one place between us. Meaning on the NAS her uploads won't be in the network mounts physical albums that I can view on my desktop etc.
Last edited by raupie (2024-08-23 10:23:30)
Offline
I might be late, but maybe someone stumbles on this, who felt as defeated as I did for a whole day, or maybe longer, anyway...
I solved the upload issue via a script that runs regularly, it handles everything automatically.
To reiterate the use case, you want family members to upload to their own (potentially private) folders, but all uploaded files go to one blob of a folder that defies your physical album structure.
This script allows new albums to be created but it can be edited such that if a physical album is not found, the operation is skipped.
Anyway... here it is:
==============================================================
```
#!/bin/bash
# run this next to ./galleries and ./upload ideally that are bound to the docker container
# otherwise you'd need to fiddle with some stuff mainly the query in line 27
# this assumes the mysql DB is inside a docker container, otherwise you'd need to edit line 23
# Configuration
db_user="<DB_USER>"
db_pass="<DB_PASSWORD>"
db_name="<DB_NAME>"
base_dir="./galleries"
log_file="./move_log.txt"
db_container="<DB_CONTAINER_NAME>"
# Function to log messages
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$log_file"
}
# Function to execute SQL queries
run_sql() {
docker exec $db_container mysql -u "$db_user" -p"$db_pass" -D "$db_name" -se "$1"
}
# Fetch all images with path like "./upload/%"
images=$(run_sql "SELECT images.id, images.file, images.path, images.storage_category_id, GROUP_CONCAT(parent_albums.name ORDER BY parent_albums.id SEPARATOR '/') AS full_virtual_path FROM piwigo_images AS images JOIN piwigo_image_category AS ic ON images.id = ic.image_id JOIN piwigo_categories AS albums ON ic.category_id = albums.id JOIN piwigo_categories AS parent_albums ON FIND_IN_SET(parent_albums.id, albums.uppercats) WHERE path LIKE './upload/%' GROUP BY images.id")
# Loop through each image and process it
while IFS=$'\t' read -r file_id file_name file_path storage_cat_id target_path; do
log_message "Processing $file_path"
# Get source directory info
source_dir=$(dirname "$file_path")
old_file_name=$(basename "$file_path" | sed 's/\.[^.]*$//')
log_message "Old filename: $old_file_name"
log_message "Source directory: $source_dir"
# Get target category (physical album)
read -r target_cat_id <<< $(run_sql "SELECT category_id FROM piwigo_image_category WHERE image_id=$file_id LIMIT 1")
read -r target_cat_name target_cat_path <<< $(run_sql "SELECT name, dir FROM piwigo_categories WHERE id=$target_cat_id")
target_full_path="$base_dir/$target_path/$file_name"
log_message "Moving file from $file_path to $target_full_path"
# Check if target directory exists, create if not
if [ ! -d "$base_dir/$target_path" ]; then
mkdir -p "$base_dir/$target_path"
chmod 755 "$base_dir/$target_path"
log_message "Created target directory $base_dir/$target_path"
fi
# Move the file
if mv "$file_path" "$target_full_path"; then
chmod +x "$target_full_path"
# Update database with new file path
run_sql "UPDATE piwigo_images SET file='$(basename "$target_full_path")', path='$target_full_path', storage_category_id=$target_cat_id WHERE id=$file_id"
run_sql "DELETE FROM piwigo_image_category WHERE image_id=$file_id AND category_id=$storage_cat_id"
run_sql "INSERT INTO piwigo_image_category (image_id, category_id) VALUES ($file_id, $target_cat_id)"
log_message "Successfully moved $file_name to $target_full_path"
else
log_message "ERROR: Failed to move $file_name. Check permissions."
continue
fi
# Move Representative (if exists)
rep_ext=$(run_sql "SELECT representative_ext FROM piwigo_images WHERE id=$file_id")
log_message "Representative extension: $rep_ext"
if [ -n "$rep_ext" ]; then
source_rep_path="./$source_dir/pwg_representative/$old_file_name.$rep_ext"
target_rep_path="$base_dir/$target_path/pwg_representative/${file_name%.*}.$rep_ext"
if [ -f "$source_rep_path" ]; then
if [ ! -d "$base_dir/$target_path/pwg_representative" ]; then
mkdir -p "$base_dir/$target_path/pwg_representative"
fi
if mv "$source_rep_path" "$target_rep_path"; then
chmod +x "$target_rep_path"
log_message "Moved representative image to $target_rep_path"
else
log_message "ERROR: Failed to move representative image."
fi
fi
fi
# Cleanup empty directories
rmdir --ignore-fail-on-non-empty "$source_dir" 2>/dev/null && log_message "Removed empty source folder $source_dir"
log_message "Move operation completed for image ID $file_id"
done <<< "$images"
log_message "All move operations completed."
```
==============================================================
Credit: Myself and it was supported by the "move to physical album" extension
(without it I was lost as to what to do in the DB)
HAPPY HACKING!
Offline
Somethings to improve about the script:
The query can simply track every moved file (not just uploaded ones) by checking that
`CONCAT(BASE_DIR, full_virtual_path, '/', images.file) <> images.path`
BASE_DIR is normally ./galleries/
You can also add this block after the query to avoid filling the log with unnecessary error messages when there is nothing to process
if [ -z "$images" ]; then
log_message "No images were uploaded/moved. Exiting script."
exit 0
fi
Last edited by MHkaserz (2025-03-02 02:42:58)
Offline