img
Shrink large images (over 512 KB) in place so they fit within 800×600 pixels
- Command:
/go/img - Category: Files and media
- Required arguments:
<domain|directory|file|all> - Output: Plain text (one progress line per image)
- Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also
Overview
/go/img reduces the size of oversized images on a server, which saves disk space and speeds up pages. It:
- finds
.webp,.jpeg,.jpg, and.pngfiles larger than 512 KB - resizes each one to fit inside an 800×600 box, keeping its proportions
- overwrites the original file
- can split the work into 16 background jobs for folders with very many files (
--md5)
[!WARNING] The original image is replaced and cannot be recovered by this command. There is no backup and no dry run. Run it on one folder first, and take a backup with
backuporsnapshotbefore using it on a whole site. Avoidallunless you are sure every account may be shrunk, because it processes every image under/home.
Quick start
# Shrink all large images on one site
/go/img example.com
Syntax
# One site, folder, or file
/go/img <domain|directory|file> [prefix]
# All accounts
/go/img all [prefix]
# Many files: run 16 background jobs, one per starting character
/go/img <domain|directory> --md5 [--skip log]
Arguments
| Position | Argument | Required | Notes |
|---|---|---|---|
| 1 | domain, directory, file, or all |
Yes | What to process. See How the first argument is read. |
| 2 | prefix |
No | Only files whose name starts with this text. Ignored if it contains --. |
| any | --md5 |
No | Splits the work into 16 background jobs. See --md5 mode. |
| any | --skip log |
No | With --md5, skips any job that already has a log file. Written as two words. |
How the first argument is read
| Order | Check | Result |
|---|---|---|
| 1 | Is it an existing file or directory? | Used as given, relative to your current folder. |
| 2 | Is it all? |
Searches /home, which covers every account. |
| 3 | Does /home/<value>/www exist? |
Searches that folder. |
| 4 | None of the above | <value> does not exist and the command stops. |
What gets resized
| Rule | Detail |
|---|---|
| Extensions | .webp, .jpeg, .jpg, .png. Lowercase only. .gif and uppercase names such as PHOTO.JPG are ignored. |
| Size | Larger than 512 KB. Smaller files are left alone. |
| Result size | Fits within 800 pixels wide and 600 pixels high, with the proportions kept. |
| Prefix | The prefix matches the start of the file name, not the folder. It can contain * wildcards. |
A tall image becomes at most 600 pixels high, so a portrait photo ends up much narrower than 800 pixels.
Output
| Situation | Message |
|---|---|
| Resizing an image | [<number>/<total>] Resizing <path>... |
| No matching files | No output |
| Target not found | <value> does not exist (exit code 1) |
--md5 job started |
/go/img <target> <char>, then LOG File: /var/log/go/img/<domain>-<char>.log, then a line of dashes |
--md5 job skipped |
/go/img <target> <char> | Skipped |
In --md5 mode the command returns at once, with exit code 1, while the jobs keep running. The per-file progress goes to the log files.
Examples
# All large images on a site
/go/img example.com
# One folder
/go/img /home/example.com/www/wp-content/uploads
# One file
/go/img /home/example.com/www/images/banner.png
# Only files whose names start with "2024"
/go/img example.com 2024
# Large folder of hash-named files, in 16 background jobs
/go/img example.com --md5
# Run again, skipping jobs that already have a log
/go/img example.com --md5 --skip log
# Follow one background job
tail -f /var/log/go/img/example.com-a.log
# Preview which files would be touched (plain find, changes nothing)
find /home/example.com/www -type f \( -name "*.webp" -o -name "*.jpeg" -o -name "*.jpg" -o -name "*.png" \) -size +512k
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
<value> does not exist |
No such file or folder, and no /home/<value>/www. |
Check the spelling, or pass a full path. |
convert: command not found |
ImageMagick is not installed. | Install ImageMagick with the server's package manager. |
| Images look small or squashed | They were scaled to fit 800×600. Portrait images end up at most 600 pixels high. | Restore the originals from a backup, snapshot, or recover. |
| A small image became larger | The size has no "shrink only" flag, so an image under 800×600 that is over 512 KB (often a PNG) is enlarged to fit. | Restore it from a backup. |
unable to open image |
The path has a space in it. The paths are not quoted. | Rename the file or folder. |
| The same images are processed on every run | A resized file can still be over 512 KB, especially PNG photos. JPEG files lose a little quality each time. | Convert them with webp instead. |
| Nothing happens | No file matches: wrong extension case, a .gif, or all files are under 512 KB. |
Run the preview find from Examples. |
| Some files fail with permission errors | The resizing step does not use sudo, so it needs root. |
Run the command as root. |
Server is slow during --md5 |
16 jobs run at once. | Run at a quiet time, and watch with cpu and mem. |
--skip log skipped a job that did not finish |
A job's log file exists as soon as the job starts, even if it was interrupted. | Delete that log file in /var/log/go/img/ and run again. |
--md5 left many files untouched |
It only handles names that start with 0-9 or a-f in lowercase. |
Run without --md5 for the other names. |
Details
What it does
flowchart TD
A["/go/img target [prefix]"] --> B["Append the command to /var/log/go/img.log"]
B --> C{"Target found?"}
C -- "No" --> D["Print error and exit"]
C -- "Yes" --> E{"--md5 given?"}
E -- "Yes" --> F["Start 16 background jobs, one per character"]
F --> G["Exit at once"]
E -- "No" --> H["Find images over 512 KB, filtered by prefix"]
H --> I["For each image: resize to fit 800x600 and overwrite"]
Steps in order
- Appends a timestamped line with the arguments to
/var/log/go/img.log. - Works out what to search (see How the first argument is read).
- If
--md5was passed, starts the background jobs and exits (see below). - Otherwise takes the prefix from argument 2, unless it contains
--. - Lists
.webp,.jpeg,.jpg, and.pngfiles over 512 KB, filtered by the prefix if there is one. - For each file, prints a progress line and runs ImageMagick
convertwith-resize 800x600, writing the result over the original.
--md5 mode
Designed for folders where files are named with hash values (for example MD5), so their names begin with a hexadecimal character. It starts one background job for each of these 16 characters, and each job handles only files whose names start with that character.
| Item | Value |
|---|---|
| Characters | a b c d e f 0 1 2 3 4 5 6 7 8 9 (lowercase) |
| Job command | /go/img <target> <char>, started with nohup so it survives logout |
| Log file | /var/log/go/img/<domain>-<char>.log |
| Domain in the log name | The third part of a path such as /home/example.com/www, or the whole value if you pass a plain domain. |
- Each job searches the whole target again, so the folder is scanned 16 times.
- Log names use only the domain. Two folders of the same domain share log names, so
--skip logcan skip the wrong job. - Without
--skip log, existing log files are overwritten. - To stop the jobs, find them with
ps aux | grep '[g]o/img'andkillthe process IDs. A resize already in progress may need to be stopped separately.
Notes
- The size limit is 512 KiB, measured on the file as stored.
- Only the file's name is compared with the prefix, so
2024matches2024-photo.jpgbut notphoto-2024.jpg. - Spaces in a folder or file name break the command, because the paths are not quoted.
- The command only shrinks images that already exist. To remove images the database no longer uses, see
img-out-db.
See also
| Command | Description |
|---|---|
webp |
Convert images to WebP format |
installwebp |
Install WebP support in GoAdmio |
img-out-db |
Remove images not found in the MySQL database |
pdf |
Compress PDF files in a site directory |
backup |
Create a backup for all GoAdmio accounts (local and remote) |
snapshot |
Restic-based per-domain snapshot backup and restore |
recover |
Restore a deleted account from its latest snapshot |
cpu |
Check the top ten CPU-consuming commands or services |