mirror of
				https://github.com/axllent/goptimize.git
				synced 2025-11-04 03:48:28 -05:00 
			
		
		
		
	Compare commits
	
		
			7 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					f9bf16d6c4 | ||
| 
						 | 
					6c1aabaa70 | ||
| 
						 | 
					8c3e478384 | ||
| 
						 | 
					7ffb944b0f | ||
| 
						 | 
					cb4bde8c4e | ||
| 
						 | 
					49d7b9b12f | ||
| 
						 | 
					fcdbf3e90b | 
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,2 @@
 | 
				
			|||||||
/dist/
 | 
					/dist/
 | 
				
			||||||
goptimize
 | 
					goptimize*
 | 
				
			||||||
@@ -1,5 +1,11 @@
 | 
				
			|||||||
# Changelog
 | 
					# Changelog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## [dev]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Switch to go mods - go (>= 1.11 required)
 | 
				
			||||||
 | 
					- Switch to axllent/semver for app updating
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.0.3]
 | 
					## [0.0.3]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Detect & skip animated GIFs
 | 
					- Detect & skip animated GIFs
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							@@ -5,8 +5,7 @@ LDFLAGS=-ldflags "-s -w -X main.version=${VERSION}"
 | 
				
			|||||||
build = echo "\n\nBuilding $(1)-$(2)" && GOOS=$(1) GOARCH=$(2) go build ${LDFLAGS} -o dist/goptimize_${VERSION}_$(1)_$(2) \
 | 
					build = echo "\n\nBuilding $(1)-$(2)" && GOOS=$(1) GOARCH=$(2) go build ${LDFLAGS} -o dist/goptimize_${VERSION}_$(1)_$(2) \
 | 
				
			||||||
	&& bzip2 dist/goptimize_${VERSION}_$(1)_$(2)
 | 
						&& bzip2 dist/goptimize_${VERSION}_$(1)_$(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
goptimize: *.go
 | 
					goptimize: *.go go.*
 | 
				
			||||||
	go get github.com/disintegration/imaging golang.org/x/image/bmp golang.org/x/image/tiff github.com/axllent/gitrel github.com/spf13/pflag
 | 
					 | 
				
			||||||
	go build ${LDFLAGS} -o goptimize
 | 
						go build ${LDFLAGS} -o goptimize
 | 
				
			||||||
	rm -rf /tmp/go-*
 | 
						rm -rf /tmp/go-*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -16,7 +15,6 @@ clean:
 | 
				
			|||||||
release:
 | 
					release:
 | 
				
			||||||
	mkdir -p dist
 | 
						mkdir -p dist
 | 
				
			||||||
	rm -f dist/goptimize_${VERSION}_*
 | 
						rm -f dist/goptimize_${VERSION}_*
 | 
				
			||||||
	go get github.com/disintegration/imaging golang.org/x/image/bmp golang.org/x/image/tiff github.com/axllent/gitrel github.com/spf13/pflag
 | 
					 | 
				
			||||||
	$(call build,linux,amd64)
 | 
						$(call build,linux,amd64)
 | 
				
			||||||
	$(call build,linux,386)
 | 
						$(call build,linux,386)
 | 
				
			||||||
	$(call build,linux,arm)
 | 
						$(call build,linux,arm)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								README.md
									
									
									
									
									
								
							@@ -2,12 +2,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[](https://goreportcard.com/report/github.com/axllent/goptimize)
 | 
					[](https://goreportcard.com/report/github.com/axllent/goptimize)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Goptimizer is a commandline utility written in Golang. It downscales and optimizes JPEG, PNG and Gif files.
 | 
					Goptimizer is a commandline utility written in Golang. It downscales and optimizes JPEG, PNG, GIF, TIFF and BMP files.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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):
 | 
					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):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- jpegoptim
 | 
					- jpegtran (`libjpeg-turbo-progs`) or jpegoptim
 | 
				
			||||||
- jpegtran (`libjpeg-turbo-progs`)
 | 
					 | 
				
			||||||
- optipng
 | 
					- optipng
 | 
				
			||||||
- pngquant
 | 
					- pngquant
 | 
				
			||||||
- gifsicle
 | 
					- gifsicle
 | 
				
			||||||
@@ -15,14 +14,16 @@ Image downscaling/rotation is done within goptimize (`-m <width>x<height>`, see
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
## Notes
 | 
					## Notes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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 has definite advantages.
 | 
					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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
It is highly recommended to install the necessary optimization tools, however they are not required to run goptimize.
 | 
					It is highly recommended to install the necessary optimization tools, however they are not required to run goptimize.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Goptimize will remove all exif data from JPEG files, auto-rotating those that relied on it.
 | 
					Goptimize will remove all exif data from JPEG files, auto-rotating those that depend on it for orientation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
It will also preserve (by default) the file's original modification times (`-p=false` to disable).
 | 
					It will also preserve (by default) the file's original modification times (`-p=false` to disable).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Animated GIF files are not supported and automatically get skipped.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Usage options
 | 
					## Usage options
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -56,11 +57,16 @@ Options:
 | 
				
			|||||||
## Install
 | 
					## Install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Download the appropriate binary from the [releases](https://github.com/axllent/goptimize/releases/latest), or if you have golang installed 
 | 
					Download the appropriate binary from the [releases](https://github.com/axllent/goptimize/releases/latest), or if you have golang installed 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Build requirements
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Go >= 1.11 required.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
go get github.com/axllent/goptimize
 | 
					go get github.com/axllent/goptimize
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
## TODO
 | 
					## TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Some ideas for the future:
 | 
					Some ideas for the future:
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								go.mod
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					module github.com/axllent/goptimize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					go 1.13
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require (
 | 
				
			||||||
 | 
						github.com/axllent/ghru v1.1.3
 | 
				
			||||||
 | 
						github.com/disintegration/imaging v1.6.1
 | 
				
			||||||
 | 
						github.com/spf13/pflag v1.0.5
 | 
				
			||||||
 | 
						golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										12
									
								
								go.sum
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								go.sum
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					github.com/axllent/ghru v1.1.3 h1:n0jYsuqCYaHHAR6DraXZl8hpBY4j0XV47y5Lyym/jGo=
 | 
				
			||||||
 | 
					github.com/axllent/ghru v1.1.3/go.mod h1:rFvMhcO1UAv2Cv6bXscS8EOc7qqNpfe8ZLp23utzs88=
 | 
				
			||||||
 | 
					github.com/axllent/semver v0.0.0-20191103011746-394cefa91ee9 h1:LHNcCfePzgC/agAJs5a/5K3hFo8uW04bEdDKDkoX4do=
 | 
				
			||||||
 | 
					github.com/axllent/semver v0.0.0-20191103011746-394cefa91ee9/go.mod h1:2xSPzvG8n9mRfdtxSvWvfTfQGWfHsMsHO1iZnKATMSc=
 | 
				
			||||||
 | 
					github.com/disintegration/imaging v1.6.1 h1:JnBbK6ECIZb1NsWIikP9pd8gIlTIRx7fuDNpU9fsxOE=
 | 
				
			||||||
 | 
					github.com/disintegration/imaging v1.6.1/go.mod h1:xuIt+sRxDFrHS0drzXUlCJthkJ8k7lkkUojDSR247MQ=
 | 
				
			||||||
 | 
					github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 | 
				
			||||||
 | 
					github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 | 
				
			||||||
 | 
					golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
 | 
				
			||||||
 | 
					golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
 | 
				
			||||||
 | 
					golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
 | 
				
			||||||
 | 
					golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
				
			||||||
							
								
								
									
										8
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								main.go
									
									
									
									
									
								
							@@ -7,7 +7,7 @@ import (
 | 
				
			|||||||
	"regexp"
 | 
						"regexp"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/axllent/gitrel"
 | 
						"github.com/axllent/ghru"
 | 
				
			||||||
	"github.com/spf13/pflag"
 | 
						"github.com/spf13/pflag"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -87,15 +87,15 @@ func main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if showversion {
 | 
						if showversion {
 | 
				
			||||||
		fmt.Println(fmt.Sprintf("Version: %s", version))
 | 
							fmt.Println(fmt.Sprintf("Version: %s", version))
 | 
				
			||||||
		latest, _, _, err := gitrel.Latest("axllent/goptimize", "goptimize")
 | 
							latest, _, _, err := ghru.Latest("axllent/goptimize", "goptimize")
 | 
				
			||||||
		if err == nil && latest != version {
 | 
							if err == nil && ghru.GreaterThan(latest, version) {
 | 
				
			||||||
			fmt.Printf("Update available: %s\nRun `%s -u` to update.\n", latest, os.Args[0])
 | 
								fmt.Printf("Update available: %s\nRun `%s -u` to update.\n", latest, os.Args[0])
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if update {
 | 
						if update {
 | 
				
			||||||
		rel, err := gitrel.Update("axllent/goptimize", "goptimize", version)
 | 
							rel, err := ghru.Update("axllent/goptimize", "goptimize", version)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			fmt.Println(err)
 | 
								fmt.Println(err)
 | 
				
			||||||
			os.Exit(1)
 | 
								os.Exit(1)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user