jpegoptim - reclaiming phone storage space for free¶
The problem¶
Recently, my phone ran out of space. I was trying to take some videos, but my phone's camera app couldn't even launch with how little free space I had. I tried deleting some apps and some large videos, but I was wondering if I could quickly reclaim some space for "free," so to speak, without losing information of value.
In this respect, videos offer a lot of space-saving potential, but this time around I wanted a quicker solution. Usually re-encoding video takes a while, even on a computer with a dedicated GPU.
Imagepipe¶
I first stumbled upon Imagepipe, a simple app that uses Android intents to quickly edit, compress, strip EXIF data, etc. from images using the Android share function. Bonus points for not requiring internet access, and being very performant. However, I have a loot of photos, and going through them one by one was guaranteed to take a long time.
jpegoptim¶
I then realized that I didn't need to do all my processing on the phone itself. Using KDE Connect, I can mount my phone's filesystem over WiFi to my Kubuntu machine. It's honestly pretty awesome.
Enter jpegoptim, a terminal-based package available in the default Ubuntu repositories. By running jpegoptim --preserve *.jpg, modification times are preserved, and jpegoptim does lossless compression. For each image, (iirc) I was getting ~10% reduction in file size for no loss of information. Spread out across hundreds of images, the saved space was noticeable. jpegoptim also supports lossy compression by specifying a target final file size, or a percentage of the original size.
Counterpoints¶
But, I can hear you saying, why not use apps like Files (from Google), or the (probably) millions other storage space freeing utilities on the Play Store? The answer is that I don't trust them to not poke through my files, especially if they have the Internet permission. Why should a file manager need access to the internet, if the files are already on-device?
But what about Termux? The answer is that although I think that Termux is a great project, I just don't feel that comfortable giving it access to my files yet. It has a large community base and is generally trusted, so not using it is more personal preference than actual apprehension.