From 8f561a95864de090624c0b35ab54d151bc191130 Mon Sep 17 00:00:00 2001 From: Drew Haven Date: Wed, 2 Sep 2026 11:23:46 -0700 Subject: [PATCH] Adds a note for an imagemagick command that resizes and optimizes. --- src/content/notes/NixOS/Useful Utilities.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/content/notes/NixOS/Useful Utilities.md b/src/content/notes/NixOS/Useful Utilities.md index 2c6f0e3..d9e91e9 100644 --- a/src/content/notes/NixOS/Useful Utilities.md +++ b/src/content/notes/NixOS/Useful Utilities.md @@ -11,3 +11,11 @@ Here's a small collection of various utilities and recipes I find useful. It's n ```bash nix run 'nixpkgs#jpegoptim' -- --max=85 --strip-all *.jpg ``` + +The major issue with `jpegoptim` is that it doesn't do resizing. Image Magick is the Swiss army knife of image manipulation and can do it all, but it's a much larger piece of software. This can quickly reduce a full-size camera image (~5MB) to something suitable for web uploads, thumbnails or avatars (50kB). + +```bash +nix run 'nixpkgs#imagemagick' -- input.jpg -resize 1200x800 -strip -quality 85 output.jpg +``` + +There are lots of options that can be passed to the [image geometry](https://imagemagick.org/command-line-processing/#geometry). The default for pixel sizes is to treat it as a maximum and preserve the aspect ratio. If only a width is given then height is automatically determined from the aspect ratio.