Read the statement by Michael Teeuw here.
Sync a Google folder for background photos
my plan is to use my phone to get photos on my MM as easily as possible to display in the background. I also want other family members to be able to save photos.
I have the following idea and attempted solutions and am posting them here for discussion.
- copy the photos from the cellphone to a google drive
- the google drive is accessible to the family
- Google-Drive synchronizes with a folder on the Raspberry
- the photos are converted to the right format (resolution and file format) on the Raspberry
- the converted photos are displayed as background in MM
So far I have managed it. I’m also writing this a bit for me as a doc so I can get it installed again in the future. Feedback and improvements are very welcome though.
- Create a dedicated MM folder on my Google drive
- Use rclone to synchronize between Raspberry and google drive: https://github.com/rclone/rclone
- How to: https://ostechnix.com/mount-google-drive-using-rclone-in-linux/
- You have to use your own google client-id for rclone, see here: https://rclone.org/drive/#making-your-own-client-id
rclone sync googleDrive:MagicMirror /home/pi/Pictures/
Now you have all pictures synced in pi/Pictures. If you delete a picture in the google-drive it will be deleted on the pi the next time you run the script. That’s what I want to happen.
Now begins the part where I’m not 100% happy yet. MM can only display JPEGs. But from the iPhone I get heic files. So they still have to be converted.
I do that with: https://imagemagick.org/script/mogrify.php
In the code it looks like this:
mogrify -path /home/pi/MagicMirror/modules/MMM-BackgroundSlideshow/ImagesJPEG -format jpeg -resize 2560x1440 /home/pi/Pictures/*
All images in all formats that can be found in /home/pi/Pictures/* will be converted to JPEG in 2560x1440 pixels and saved to /home/pi/MagicMirror/modules/MMM-BackgroundSlideshow/ImagesJPEG.
I then specified this location as the image path in MMM-BackgroundSlideshow.
So far so good. My problem is now, I want to delete the deleted images in google Drive also on the pi. A simple synchronization does not work, because in the google folder are heic files and in my MM are now the converted JPEGs.
My workaround is that I clear the pictures folder in MM every time and fill it all over again after a new sync.
rm -rf /home/pi/MagicMirror/modules/MMM-BackgroundSlideshow/ImagesJPEG/*
This is not only slow but also kind of stupid. But I can’t think of a better solution yet.
Oh, and the whole thing is supposed to run in a script once an hour later, but I’m not there yet. I have never dealt with scripts on the Pi.
I look forward to suggestions for improvement from you.
@MajorC can u get the list of pictures on GDrive?
I assume you convert xxx.heic to xxx.jpg
then get the list of jpeg files, and remove from the list all that are in GDrive list
those leftover on jpeg list were removed
those leftover on GDrive list were added