IOS uses shortcut commands to upload compressed screenshots to Google Photos

This article was published on , the content may be different from the actual situation. If there are errors in the article, please correct them. I will modify or hide the article according to the situation

Note: This method requires a server located overseas that can access Google, or set up a server to use after configuring scientific Internet access at home

Recently, Google Photo has charged a fee. Considering that the backup images in my photo album in the past five years are either screenshots or acerbic images, they have occupied 47G so far (rclone has been pulled to the local place for backup, and the size has been compressed by Google). Although it is not expensive, it feels very bad at this growth rate.
Heard that the compression rate of HEIF is amazing, and the test on the mobile phone found that it is true. Google photo albums also support uploading, but may not provide users with conversion function due to copyright reasons. So you need to complete the conversion on your phone before uploading.

The steps are as follows:
1. The iOS terminal acquires all the photos in the album through Shortcut, converts them to HEIF format one by one, judges the size changes before and after and uploads them to the server, and finally deletes the local photos.
2. The server writes the photo date to EXIF through exiftool (because rclone cannot synchronize the modification time of the image file itself to Google Portal
3. The server moves the written image into the rclone's mount directory (specifically, Google Photo: upload/directory)
4. Turn off automatic upload of Google Photo

First is the shortcut script

Link: https://www.icloud.com/shortcuts/278f6f64ddf4409d9453636be5c49382

The server downloads Exiftool and unzips it

 cd /opt wget  https://exiftool.org/Image-ExifTool-12.23.tar.gz tar -zxf Image-ExifTool-12.23.tar.gz

Install Nginx+PHP

Install rclone and add Photos configuration (Debian is taken as an example here. Centos please download the rpm package on the official website)

 cd ~/ wget  https://downloads.rclone.org/v1.55.0/rclone-v1.55.0-linux-amd64.deb dpkg -i rclone-v1.55.0-linux-amd64.deb rclone config # n) New remote # name> GooglePhoto ## 16 / Google Photos ##   \ "google photos" # Storage> 16 ## OAuth Client Id ## Leave blank normally. ## Enter a string value.  Press Enter for the default (""). # client_id> ## OAuth Client Secret ## Leave blank normally. ## Enter a string value.  Press Enter for the default (""). # client_secret> ## Set to make the Google Photos backend read only. ##  ## If you choose read only then rclone will only request read only access ## to your photos,  otherwise rclone will request full access. ## Enter a boolean value (true or false).  Press Enter for the default ("false"). # read_only> ## Edit advanced config?  (y/n) ## y) Yes ## n) No (default) # y/n> n ## Remote config ## Use auto config? ##  * Say Y if not sure ##  * Say N if you are working on a remote or headless machine ## y) Yes (default) ## n) No # y/n> n ## Please go to the following link:  https://accounts.google.com/o/oauth2/auth?XXXXXXXXXXXXXXXXXX ## Log in and authorize rclone for access # Enter verification code> XXXXXXXXXX ## -------------------- ## [XXXXX] ## client_id =  ## client_secret =  ## token = XXXXXX ## -------------------- ## y) Yes this is OK ## e) Edit this remote ## d) Delete this remote # y/e/d> y

Mount Photos to the local directory (write only)

 apt update && apt install -y fuse mkdir /mnt/GooglePhotos cat > /etc/systemd/system/rclonephotos.service <<EOF [Unit] Description=rclone GooglePhotos [Service] User=root ExecStart=/usr/bin/rclone mount GooglePhoto: upload//mnt/GooglePhotos/-- allow other -- allow non empty -- vfs cache mode full -- default permissions -- uid [uid of www data] -- gid [gid of www data] -- umask 027 ExecStop=/usr/bin/fusermount -u /mnt/GooglePhotos/ Restart=on-abort [Install] WantedBy=multi-user.target EOF systemctl enable rclonephotos --now service rclonephotos status ## Active: active (running) ls -l /mnt ## drwxr-x--- 1 www-data www-data    0 Apr 12 16:17 GooglePhotos

Finally, upload the script (file verification is too lazy to do anyway, there is a password)

 <? php ini_set('display_errors',1); date_default_timezone_set('Asia/Shanghai'); header('Content-Type:text/plain;  charset=utf-8'); if((!isset($_SERVER['PHP_AUTH_USER']) || ! isset($_SERVER['PHP_AUTH_PW'])) || ! ($_SERVER['PHP_AUTH_USER'] == 'test' && $_SERVER['PHP_AUTH_PW'] == 'testtest')){ header('WWW-Authenticate: Basic realm="Authentication"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authentication invalid.'; exit; } if(empty($_FILES['file']['tmp_name']) || ! is_uploaded_file($_FILES['file']['tmp_name'])){ header('HTTP/1.0 403 Forbidden'); echo 'Invalid file source.'; exit; } @unlink("/tmp/{$_FILES['file']['name']}"); if(move_uploaded_file($_FILES['file']['tmp_name'],"/tmp/{$_FILES['file']['name']}") === FALSE){ header('HTTP/1.0 500 Internal Server Error'); echo 'Could not move temporary file.'; exit; } $time = strtotime($_POST['time']); $exiftime = date('Y:m:d H:i:s',$time); exec("/opt/Image-ExifTool-12.23/exiftool -alldates='$exiftime' /tmp/{$_FILES['file']['name']}"); rename("/tmp/{$_FILES['file']['name']}","/mnt/GooglePhotos/{$_FILES['file']['name']}"); echo 'Success.';

Final effect:

Original document Google Photo High Quality HEIF format

(Google is not trying to solve the problem at all.)

label: ios , shortcut , photos , google photos , heif , Quick Instructions , Picture compression , heic

Only one comment

  1. Puhaha, Google is lonely

Add a new comment