webp-purger is a CLI tool that walks through a path you give it and converts every valid .webp file it finds.
If you've ever been searching for photos to use in your slideshows and kept downloading WebP files, you'd know my pain.
That's why I built this tool.
It was a nice project to work on, and I got a ton of learning experience from it.
If you want to see how it works internally, check out the How It Works section.
I was able to finish the project in around 5 days.
Updates may come in the future.
You can get the executable from the Releases page, or you can build it yourself.
git clone https://github.com/emir12311/webp-purger
cd webp-purger
makeThis will create a webp-purger executable in dist.
You can move it somewhere in your PATH, or use it directly:
dist/webp-purgerTo remove the object files after building:
make cleanThe usage is pretty simple.
webp-purger <path_to_directory>| Flag | Description |
|---|---|
--force |
Don't prompt on failed files. |
--include-hidden |
Include files and directories that start with .. |
--verbose |
Show full errors for file errors. |
The tool takes the path you give it and calls walk() on it.
- The given directory is opened.
- The files and directories inside it are read and looped through.
- If an entry is another directory,
walk()is called on it again. - If an entry is a file,
webp-purgerchecks whether it is a WebP image. - If it is a WebP image, it is converted to PNG.
- If the conversion succeeds, the original WebP file is moved to
.webptrashedin your home directory.
In short:
Directory
│
├── Directory ──→ walk() ──→ ...
│
└── File
│
├── WebP ──→ Convert ──→ PNG
│ │
│ └── Original → ~/.webptrashed
│
└── Not WebP ──→ Ignore
That's basically it.
This project is licensed under the GNU General Public License v3.0.
See the GNU GPL v3 for the full license text.
