Save space by resizing Google Photos

On the 1st of June 2021, Google Photos stopped offering free storage.

Google Photos is a fantastic service, but at the rate I take photos I knew I’d fill the remaining gigabytes of storage in a matter of months, so I stopped uploading photos from my phone.

I don’t regard Google Photos as a backup system for my photos. I use Backblaze for that, where everything is backed up from my desktop computer. Google Photos is very useful for sharing albums, the face recognition is amazing, and utilities like HDR photo generation and time lapses are nice bonuses.

In Lightroom, I would resize images to 16MP before uploading them to Google Photos. Those files are still huge compared to what you really need. They are likely only going to be seen on a screen, either phone or laptop. So recently I started to resize them to 1280 pixels on the longest side. Instead of a 6,000Kb file, I now upload a 600Kb file. On my phone screen it looks much the same, and I have the original on my computer anyway!

What I really wanted is for my phone to resize the images I shoot and then allow Google Photos to upload them. It would have to do something like this:

  1. Check the DCIM/Camera directory for new photos, and move them to a work directory.
  2. Go through those images, resize them and copy the location EXIF data from the original images.
  3. Save the resized images to a new directory in DCIM where Google Photos will back them up.
  4. Some time later, those resized images should be deleted when we’re sure they’ve been backed up.

With the help of Tasker, an Android app, I was able to do that, and more. Tasker is a tool that lets you automate tasks on your phone. It can do simple things like enable screen rotation when Google Photos or Lightroom are launched. Or it can disable your Wi-Fi if you leave the house.

First, the bad news. The Tasker app costs money, and it’s complicated to use. However, it’s not expensive and there are lots of public Tasker projects on their Taskernet website, which means you probably won’t need to delve into the complexity of it. Much.

Over the course of a few weeks I figured out how to program Tasker to do what I wanted, and if you look at my Taskernet Profile you’ll see the result of that work. The final work on copying the EXIF data took me three hours on the train back from Dublin, and then a hint on Reddit to complete.

The Resize Images for Google Photos Tasker profile does exactly what it says. It moves new photos out of the way, resizes them, and copies the location data to the new files. The original files are moved to Download/jpeg. Finally, it saves the resized images back in a DCIM directory, where Google Photos will find them and upload them.

Every time a photo is taken, it checks if any existing resized photo is more than 7 days old and deletes it, which should be more than enough time for it to be uploaded to Google Photos.

It also moves MP4 files out of the way to Download/jpeg because MP4 files can be huge! You could resize those with Handbrake on your desktop machine before uploading to Google Photos.

Tasker task source code

You install it through Tasker itself or by loading this blog post on your phone. Tap on this Resize Images for Google Photos link, which will bring you to Taskernet. You can also find it by searching for the tags, Files and Camera.

Read the description, and please make a backup of your photos first. Tap Import and Tasker will load. A warning about the commands used now shows.

It does execute Java code, but that’s only to copy the EXIF data to the resized images. It uses shell commands to move files around or delete thumbnails and old files.

When it asks for the profile, just tap on Base, if you don’t have any others. If you are worried about running unknown code on your phone, don’t enable it. Take a look at the “Resize Jpeg Files” task. You can see all 39 lines of code.

Some notes on implementation:

  • The profile monitors the DCIM/Camera directory for new files. If your favourite camera app puts photos somewhere else, they won’t be found.
  • Some paths are hard coded. The ExifInterface library requires a filename. It expects that the Resized directory is in /storage/emulated/0/DCIM/. If it isn’t there, edit line 25. Three shell commands run at the end and use /sdcard/DCIM/. That should be edited too if necessary.
  • Photos are moved to Download/WIP to be resized.
  • After resizing, they are saved to DCIM/Resized.
  • Photos are resized to a maximum width of 1280px, so portrait orientation images will be bigger.
  • Your gallery app will show the resized images as duplicates unless you can hide the Resized directory.
  • The gallery in your camera app is going to show broken images. Your favourite gallery app may not even show the images. I find the Piktures app regenerates the thumbnails properly, but the Samsung and Xiaomi gallery apps don’t. Neither does Google Photos, so if anyone knows how to fix that, I’m all ears!

This might seem like a lot of trouble to save some space in my Google account, but this is something Google could have done themselves. Sure, they have the storage saver setting. That resizes large photos down to 16MP but, even saved in WebP format or something, the files are fairly big. It was an itch I had to fix. Besides all that, Tasker is a very powerful tool that I wanted to use more!

My photos don’t stay on my phone. I use Syncthing to synchronise a few different directories with my desktop machine. Every few days I import them into Lightroom. Importing them moves them, and being removed from the Camera directory is synchronised back to the phone, so the photos are deleted from the phone. From Lightroom they’re backed up in various ways. I actually run a small shell script to move photos taken by various apps into one directory, and check if duplicate DNG/Jpeg files exist, but that’s a topic for another blog post.

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close