Compressing the Images in Anki’s Media Folder to Save Disk Space

This article is a follow-up to my introduction to Anki. When I go through lecture notes or some other source material, I take quite a lot of screenshots. Despite the use of image resizing add-ons, screenshots can occupy a lot of disk space. In this article, I show you how I save disk space by compressing the images without messing up the Anki database or worsening the image quality.

If you’re using macOS, I recommend the excellent program ImageOptim. Otherwise, try a similar tool, e.g., FileOptimizer (Windows) or Trimage (Linux).

With ImageOptim, you just drag and drop Anki’s media collection folder onto the app icon in your dock or onto the GUI and let ImageOptim do the rest. Images that had already been optimised in a previous run will not be modified again, so no need for filtering out already optimised images or selecting only the new ones.

In its settings, you can decide which compression algorithms you want ImageOptim to choose from. ImageOptim always uses the algorithm that is the best fit in that situation. I strongly advise to deactivate both PNGOUT and Guetzli, since they are extremely computationally expensive. While they are good algorithms, for our use case they are not worth the effort.

In the “Optimisation level” register, you can specify how much the chosen compression algorithm should compress the images. Keep in mind that dropping an entire folder containing lots and lots of images onto ImageOptim to compress them all in one pass, can go quite hard on your CPU. Optimising images is a computationally expensive process, so Insane, in this case, really means insane. Every setting higher than Extra tends to make my MacBook’s fans go crazy, even if it’s just four or five PNG images at a time, so I leave this setting at Normal.

The unoptimised image will be replaced by a smaller copy with the exact same file name at its original location, i.e., you don’t need to worry about messing up your Anki flashcards or breaking the connection between the cards and the images. The original image will be moved into the system trash, so if you overdid it with the lossy compression, you can always restore the original image and try it again with a less aggressive compression setting.

Obviously, when you next sync your media collection in Anki, you’ll have to re-upload all modified images, so the next sync may take a minute or two.

That’s it. I hope you find this article helpful. For more useful tips, be sure to follow me on Twitter to get notified when I publish a new post. Thanks, and take care.

As an Amazon Associate I earn from qualifying purchases.
Built with Hugo
Theme Stack designed by Jimmy