Compress images before PicGo uploads them, and optionally convert them to AVIF, WebP, JPEG or PNG. The plugin also adds a picgo tinify command for compressing local files.
The first engine is the TinyPNG API. More engines are planned; the engine is a setting, so they will appear there without changing anything else.
- PicGo 3.0.0 or later (GUI), or PicGo-Core 3.0.0 or later (CLI), on Node.js 20.19 or later.
- A TinyPNG API key. Get one free at tinypng.com/developers; the free plan covers 500 compressions a month.
GUI: open PicGo → Plugins, search for tinify and install it.
CLI:
picgo install tinifyGUI: Plugins → tinify → Config plugin. CLI: picgo set plugin tinify.
| Field | Meaning |
|---|---|
| Compression engine | Only TinyPNG for now. |
| TinyPNG API key | Required. Stored in PicGo's config file. The TINYPNG_API_KEY environment variable wins over the saved value. |
| Convert to | Keep format (default), AVIF, WEBP, JPEG or PNG. A converted image gets the new extension, so photo.png uploads as photo.webp. TinyPNG counts a conversion as one extra compression. |
| JPEG background | Fill for transparent areas when converting to JPEG: white (default), black or #RRGGBB. |
| Keep metadata | Any of copyright, creation time and location. TinyPNG drops all metadata by default. Location is not kept in PNG. |
| Minimum size (KB) | Images smaller than this are uploaded as they are, which saves compressions. 0 (default) compresses every image. |
Once configured, every upload is compressed first. The plugin reads the real format from the file content, so a wrong extension doesn't matter. It skips:
- files that are not images (PDF, zip, …) and images TinyPNG can't compress (GIF, SVG, or a file TinyPNG rejects): uploaded as they are, with no error or notification, even when no API key is set;
- images smaller than the minimum size;
- images TinyPNG can't make smaller without a conversion: the original is kept.
In a terminal (picgo upload, picgo tinify), a spinner shows how many images are done while they are compressed. It stays off in the GUI, in silent mode and when the output is piped.
If compression fails (no key, wrong key, monthly limit reached, network error), the original image is uploaded and the GUI shows a notification. After a wrong key or a reached limit the plugin stops calling TinyPNG for the rest of the batch.
picgo tinify a.png b.jpg # compress in place
picgo tinify *.png --convert webp # write a.webp next to a.png, keep a.png
picgo tinify *.png -o dist/ # write results into dist/, leave inputs alone
picgo tinify a.jpg --convert none # ignore the configured conversion for this run
picgo tinify a.jpg --preserve copyright,creation| Option | Meaning |
|---|---|
-o, --out-dir <dir> |
Write results to this folder (created if missing) instead of next to the inputs. |
--convert <format> |
avif, webp, jpeg, png, or none to keep the format. Default: the plugin config. |
--preserve <keys> |
Comma separated: copyright, creation, location. An empty value keeps none. Default: the plugin config. |
Without --out-dir, a file whose format doesn't change is overwritten; a converted file is written next to it with the new extension and the original stays. The command uses the API key, conversion, background and metadata settings from the config; the minimum size only applies to uploads. It exits with code 1 if any file failed.
pnpm install
pnpm build # TypeScript → dist/ (CommonJS, loaded by PicGo with require)
pnpm lint # eslint + type check
pnpm test # build, then unit and end-to-end testsThe end-to-end test loads dist/index.js into a real PicGo-Core instance and runs uploads and the CLI against a local mock TinyPNG server. TINIFY_API_URL points the plugin at that server and is not meant for normal use.
Engines live in src/engines/. A new engine implements CompressionEngine (src/engines/types.ts), gets a case in createEngine and a value in the engine config field; the upload hook and the CLI only use the interface.
The repo follows the PicGo commit convention through @picgo/bump-version: use pnpm cz to write a commit message, and the commit-msg hook checks it with commitlint.
To release, run pnpm release (patch by default, -t minor or -t major for bigger bumps). It bumps package.json, updates CHANGELOG.md, commits, and creates a v<version> tag. Push both with git push --follow-tags origin main; the tag starts the release workflow, which lints, tests, builds and publishes to npm with provenance through npm trusted publishing, so no npm token is stored in the repo.
MIT
