goptimize/README.md

77 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2019-08-02 12:46:41 +00:00
# Goptimizer - downscales and optimizes images
2019-09-07 03:16:46 +00:00
[![Go Report Card](https://goreportcard.com/badge/github.com/axllent/goptimize)](https://goreportcard.com/report/github.com/axllent/goptimize)
2019-09-07 11:08:43 +00:00
Goptimizer is a commandline utility written in Golang. It downscales and optimizes JPEG, PNG, GIF, TIFF and BMP files.
2019-08-02 12:46:41 +00:00
2019-08-24 11:26:24 +00:00
Image downscaling/rotation is done within goptimize (`-m <width>x<height>`, see [Usage](#usage-options)), however optimization is done using the following additional tools (if they are installed):
2019-08-02 12:46:41 +00:00
2019-09-07 11:08:43 +00:00
- jpegtran (`libjpeg-turbo-progs`) or jpegoptim
2019-08-02 12:46:41 +00:00
- optipng
- pngquant
- gifsicle
## Notes
2019-09-07 11:11:06 +00:00
Both `jpegoptim` & `jpegtran` have almost identical optimization, so if both are installed then just `jpegtran` is used for JPG optimization. PNG optimization however will run through both `optipng` & `pngquant` (if installed) as this can result in better optimization.
2019-08-02 12:46:41 +00:00
It is highly recommended to install the necessary optimization tools, however they are not required to run goptimize.
2019-09-07 11:11:06 +00:00
Goptimize will remove all exif data from JPEG files, auto-rotating those that depend on it for orientation.
2019-08-02 12:46:41 +00:00
It will also preserve (by default) the file's original modification times (`-p=false` to disable).
2019-09-07 11:11:06 +00:00
Animated GIF files are not supported and automatically get skipped.
2019-09-07 11:08:43 +00:00
2019-08-02 12:46:41 +00:00
## Usage options
```
Usage: ./goptimize [options] <images>
Options:
2019-08-24 11:26:24 +00:00
-q, --quality int quality, JPEG only (default 75)
-m, --max string downscale to a maximum width & height in pixels (<width>x<height>)
-o, --out string output directory (default overwrites original)
-p, --preserve preserve file modification times (default true)
2019-12-13 09:21:00 +00:00
-t, --threaded run multi-threaded (use all CPU cores)
2019-08-24 11:26:24 +00:00
-u, --update update to latest release
-v, --version show version number
-h, --help show help
--jpegtran string jpegtran binary (default "jpegtran")
--jpegoptim string jpegoptim binary (default "jpegoptim")
--gifsicle string gifsicle binary (default "gifsicle")
--pngquant string pngquant binary (default "pngquant")
--optipng string optipng binary (default "optipng")
2019-08-02 12:46:41 +00:00
```
## Examples
- `./goptimize image.png` - optimize a PNG file
- `./goptimize -m 800x800 *` - optimize and downscale all image files to a maximum size of 800x800px
- `./goptimize -m 1200x0 image.jpg` - optimize and downscale a JPG file to a maximum size of width of 1200px
- `./goptimize -o out/ image.jpg` - optimize a JPG file and save it to `out/`
2019-08-02 23:15:54 +00:00
2019-08-24 11:29:25 +00:00
## Install
Download the appropriate binary from the [releases](https://github.com/axllent/goptimize/releases/latest), or if you have golang installed
2019-10-26 09:19:46 +00:00
### Build requirements
2024-04-23 04:37:00 +00:00
Go >= 1.21 required.
2019-10-26 09:19:46 +00:00
2019-08-24 11:29:25 +00:00
```
go get github.com/axllent/goptimize
```
2019-08-02 23:15:54 +00:00
## TODO
Some ideas for the future:
- Dry run
- Option to copy exif data (how?)