compress images into webp

This commit is contained in:
Yan Lin 2026-01-30 22:04:35 +01:00
parent 50459f199d
commit ee7245f82f
70 changed files with 67 additions and 67 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View file

@ -16,11 +16,11 @@ Let's say I am currently in `~/Documents/Projects/personal-blog` and I want to j
With the classic `cd`, I will have to type the whole path.
With `cd` aliased to `zoxide`, I only need to type `cd n` (supposing that `~/.config/nix` is the most frequently visited directory among all matched directories).
![zoxide jump](zoxide-jump.png)
![zoxide jump](zoxide-jump.webp)
Internally `zoxide` records my visits to directories in a SQLite database and sorts them based on frequency. If the first hit is not what I want, I can also interactively select from the matched list.
![zoxide select](zoxide-select.png)
![zoxide select](zoxide-select.webp)
## `du` -> `ncdu`
@ -29,17 +29,17 @@ Internally `zoxide` records my visits to directories in a SQLite database and so
[`ncdu`](https://dev.yorhel.nl/ncdu) is an interactive alternative to `du`, and is very usable out of the box. Interestingly, I also feel it is a touch faster than `du`.
It can totally be an alternative to those fancy disk space analyzers as well.
![ncdu](ncdu.png)
![ncdu](ncdu.webp)
## `top` -> `btop`
`top` is quite basic and looks "unexciting". `htop` also ships with most Unix/Linux systems and looks better.
![htop](htop.png)
![htop](htop.webp)
[`btop`](https://github.com/aristocratos/btop) might be the most "nerdy-looking" `top` alternative out of the box. It can be a handy tool if you are trying to make people believe you are a hacker.
![btop](btop.png)
![btop](btop.webp)
At the same time, it is very feature-rich and configurable. To some extent, it is also an alternative to bandwidth monitoring tools like `iftop` and disk utilization tools like `df`.
@ -47,11 +47,11 @@ At the same time, it is very feature-rich and configurable. To some extent, it i
I think there is nothing wrong with the classic `ls`. So, as an alternative, [`eza`](https://github.com/eza-community/eza) just has a few quality-of-life improvements, like file type icons, Git status, and (based on personal taste) prettier colors.
![eza list](eza-list.png)
![eza list](eza-list.webp)
It can replace the `tree` command as well.
![eza tree](eza-tree.png)
![eza tree](eza-tree.webp)
## `vim` -> `nvim`
@ -63,6 +63,6 @@ You can simply use `vim` keybindings in many editors or IDEs. `vim` itself can f
To put it simply, it is a TUI editor that can truly be your only text editor. With countless plugins and ways to configure it, it can be a basic text editor, or a fully-featured development IDE, or anything in-between.
Syntax highlighting, file browser, fuzzy search, intelligent autocompletion, debugging, AI™ integration. You name it, `neovim` has it.
![neovim](nvim-1.png)
![neovim](nvim-1.webp)
![neovim fuzzy search](nvim-2.png)
![neovim fuzzy search](nvim-2.webp)

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

View file

@ -6,7 +6,7 @@ description = "How I built a NixOS-based Home Server/Nas"
This is a very concise walkthrough of my main home server running NixOS. I assume the reader already has basic knowledge about NixOS.
![cover](cover.png)
![cover](cover.webp)
My home server (or many would rather call it a NAS) serves common home server purposes: bulk storage, basic file sharing, media streaming service, and photo backup.
@ -14,7 +14,7 @@ My home server (or many would rather call it a NAS) serves common home server pu
Below is a recent photo of my home server, living in the utility closet together with my network equipments.
![server photo](server-photo.jpg)
![server photo](server-photo.webp)
It is essentially an Intel N305 custom motherboard with SATA back panel and a 3D-printed enclosure. I bought it on Taobao last time I went back to China to visit my family.
Not very important here, as long as you stick to common hardware, it should be relatively straightforward to install NixOS and replicate my setup.
@ -185,7 +185,7 @@ Transmission seems to be more stable, but its interface is so barebones and is m
For photo backup I use [Immich](https://immich.app/). It is a self-hosted alternative to iCloud Photos and Google Photos. Aside from basic photo backup and management, it also has many nice touches, such as face detection, CLIP-based image embedding for semantic search, and recently added OCR for text search. It also comes with quite robust mobile apps for both iOS and Android.
![immich](immich.png)
![immich](immich.webp)
Right now Immich is the only service I am running with containers rather than native Nix modules (as you can see in [this configuration file](https://github.com/Logan-Lin/nix-config/blob/master/hosts/nixos/hs/containers.nix)). Technically it is possible to set up Immich with pure Nix modules, but for this type of services that rely on specific versions of databases (in this case, PostgreSQL with vector support), I feel containers are the easier route.
And to be honest, I don't think there is much benefit going with pure Nix module here (especially for Immich which you can still [declare its config](https://github.com/Logan-Lin/nix-config/blob/master/config/immich.nix) even with containers), other than fulfilling the purism many Nix users seem to have.
@ -212,7 +212,7 @@ The P2P nature of Tailscale also means that, if you have no interest in creating
I don't want to complicate things so I haven't set up any automated system to check the health status of my home server and send notification if anything goes wrong.
I do have a [login display module](https://github.com/Logan-Lin/nix-config/blob/master/modules/login-display.nix) that will report important status every time I SSH into my home server.
![login display](login-display.png)
![login display](login-display.webp)
## Why NixOS?
@ -222,6 +222,6 @@ Compared to purposefully built home server systems (like Unraid) and pre-built h
Compared to other Linux distributions, NixOS is quite suitable for setting up a home server. Since it is declarative, setting up many things are probably easier than you thought. In other words, for the most part, you only have to care **what** you want to achieve, not **how** you are going to achieve them (this is of course, primarily thanks to the amazing NixOS community). On the other hand, most of the configuration is fully self-contained and tracked in your Nix config repo (supposing you use git). So it is much less prone to oversight during configuration, and you also don't have to explicitly remember your setup for future references. Before switching my home server to NixOS, I've been using Nix-darwin on my Macbook for a while, so I also get to reuse a lot of custom modules, like the [neovim module](https://github.com/Logan-Lin/nix-config/blob/master/modules/nvim.nix).
![terminal comparison](terminal-comparison.png)
![terminal comparison](terminal-comparison.webp)
> It looks completely identical (why not), to the point I have to set up visual hints (like the highlighted tmux hostname display) to remind myself which host I am currently on.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 978 KiB

View file

@ -23,7 +23,7 @@ As long as the service can achieve one functionality: always keep a full copy of
I do want to recommend a service for this purpose: [Syncthing](https://syncthing.net/). This is a peer-to-peer file sync service, which means it has minimal reliance on cloud infrastructure, and your data never has to be stored on computers that are not yours.
Also, from my experience, all cloud storage services I've used frequently run into stability issues when I try to sync tons of small files at once (e.g., a Git repo), but Syncthing is never unstable no matter how I abuse it.
![Syncthing web UI](syncthing.png)
![Syncthing web UI](syncthing.webp)
## Examples
@ -36,17 +36,17 @@ One replacement for Notion that has no reliance on cloud what so ever is [Obsidi
Every type of data needed by Obsidian, including the notes themselves, settings, plugins, and GUI customization, are stored locally (even better, in plain text).
Once you use a local file sync service to sync the vault folder of Obsidian, it works like the cloud in that everything is always in-sync, but does not have any of the downsides of the cloud.
![Obsidian](obsidian.png)
![Obsidian](obsidian.webp)
### Reference Management: Zotero
[Zotero](https://www.zotero.org/) is a reference management software that can be used in a variety of scenarios. For me, I largely use it to manage academic papers I need to read.
![Zotero](zotero.png)
![Zotero](zotero.webp)
Zotero has a built-in cloud sync functionality but their price for storage upgrades is quite high. One thing you might not know is, Zotero stores metadata and attachments in the same folder. You can use Syncthing to sync that folder, and completely ignore the official cloud sync functionality.
![Zotero folder structure](zotero-files.png)
![Zotero folder structure](zotero-files.webp)
### Paper Writing: Overleaf vs. Local Text Editor
@ -71,7 +71,7 @@ clean:
rm -rf out
```
![LaTeX editing in VSCode](latex.png)
![LaTeX editing in VSCode](latex.webp)
Overleaf also provides two types of Git integration for you to sync your local changes with Overleaf projects: sync with a GitHub repo, or directly as a remote git repo. It's totally viable to have a mixed setup, where you primarily use local editors and most of your collaborators use Overleaf.
@ -79,7 +79,7 @@ Overleaf also provides two types of Git integration for you to sync your local c
[Calibre](https://calibre-ebook.com/) is a book management software that can be used to manage your book collection, edit metadata, along with many handy functionalities like bulk conversion.
![Calibre](calibre.png)
![Calibre](calibre.webp)
Similar to Zotero, Calibre stores all the books and metadata of a library in a local folder, so there is nothing stopping you from syncing the folder across multiple computers. Although this is something explicitly suggested against by the software (a line when you select the location for a library: "Note that putting the calibre library on a Networked drive is not safe"), from my experience, as long as you don't try to open and modify the same library on two synced computers simultaneously, you won't be running into any issues.
@ -92,7 +92,7 @@ It is my own cloud infrastructure, nevertheless it is a cloud infrastructure so
Now I use a simpler yet more robust setup. I just sync all my music files in a folder through Syncthing, and use a local music player like [foobar2000](https://www.foobar2000.org/) to read that folder.
Of course, to save some space, I will always transcode each file to AAC 256k before putting them in the sync folder.
![foobar2000](foobar2000.jpg)
![foobar2000](foobar2000.webp)
## Limitations

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View file

@ -118,7 +118,7 @@ SEASONNFO
# Handle thumbnail: rename and copy as posters
local thumb_file=""
for ext in jpg webp png; do
for ext in.webp webp.webp; do
if [[ -f "$dir/$name_noext.$ext" ]]; then
thumb_file="$dir/$name_noext.$ext"
break
@ -129,11 +129,11 @@ SEASONNFO
local thumb_ext="${thumb_file##*.}"
mv "$thumb_file" "$dir/$name_noext-thumb.$thumb_ext" 2>/dev/null
if [[ ! -f "$series_dir/poster.jpg" ]] && [[ ! -f "$series_dir/poster.webp" ]] && [[ ! -f "$series_dir/poster.png" ]]; then
if [[ ! -f "$series_dir/poster.webp" ]] && [[ ! -f "$series_dir/poster.webp" ]] && [[ ! -f "$series_dir/poster.webp" ]]; then
cp "$dir/$name_noext-thumb.$thumb_ext" "$series_dir/poster.$thumb_ext"
fi
if [[ ! -f "$season_dir/poster.jpg" ]] && [[ ! -f "$season_dir/poster.webp" ]] && [[ ! -f "$season_dir/poster.png" ]]; then
if [[ ! -f "$season_dir/poster.webp" ]] && [[ ! -f "$season_dir/poster.webp" ]] && [[ ! -f "$season_dir/poster.webp" ]]; then
cp "$dir/$name_noext-thumb.$thumb_ext" "$season_dir/poster.$thumb_ext"
fi
fi
@ -144,15 +144,15 @@ I also include the thumbnail extraction logic in the implementation. The end res
```
PMM_LORD
├── poster.jpg
├── poster.webp
├── Season 2025
│   ├── poster.jpg
│   ├── poster.webp
│   ├── S2025E1031 - 【PGN】狐狸鸣泣之时——寂静岭f.mp4
│   ├── S2025E1031 - 【PGN】狐狸鸣泣之时——寂静岭f.nfo
│   ├── S2025E1031 - 【PGN】狐狸鸣泣之时——寂静岭f-thumb.jpg
│   ├── S2025E1031 - 【PGN】狐狸鸣泣之时——寂静岭f-thumb.webp
│   ├── S2025E1127 - 【PGN】卡洛斯传奇略人区——宝可梦传说ZA.mp4
│   ├── S2025E1127 - 【PGN】卡洛斯传奇略人区——宝可梦传说ZA.nfo
│   ├── S2025E1127 - 【PGN】卡洛斯传奇略人区——宝可梦传说ZA-thumb.jpg
│   ├── S2025E1127 - 【PGN】卡洛斯传奇略人区——宝可梦传说ZA-thumb.webp
│   └── season.nfo
└── tvshow.nfo
@ -175,14 +175,14 @@ And the episode `.nfo` file will record the title, upload date, and video descri
Finally, in Jellyfin/Emby, we can set up a "TV show" type library, but uncheck all the metadata fetching sources so that the information will only be provided by the `.nfo` files.
![Jellyfin library settings](jellyfin-settings.png)
![Jellyfin library settings](jellyfin-settings.webp)
And it works!
![Jellyfin result](jellyfin-result.png)
![Jellyfin result](jellyfin-result.webp)
And of course it also works nicely with third-party clients like Infuse on my mobile devices/TV.
![Infuse client](infuse-client.png)
![Infuse client](infuse-client.webp)
I packaged all my custom implementation of yt-dlp into a Nix module, which you can take a look in the [this link](https://github.com/Logan-Lin/nix-config/blob/master/modules/yt-dlp.nix) if interested.

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB