Add version
This commit is contained in:
34
README.md
34
README.md
@@ -1 +1,33 @@
|
||||
# HEIC2JPG
|
||||
# HEIC2JPG
|
||||
|
||||
## Usage
|
||||
|
||||
To convert a single file:
|
||||
|
||||
`heic2jpg myfile.heic`
|
||||
|
||||
To convert all files in a folder:
|
||||
|
||||
`heic2jpg -dir ./MyPhotos -r`
|
||||
|
||||
You can create new files in another folder with the `-o` argument
|
||||
|
||||
Other arguments are available on `-h`
|
||||
|
||||
## Build
|
||||
|
||||
The tool contains C code, so you need to activate cgo to compile it.
|
||||
|
||||
`go build`
|
||||
|
||||
I compile with the following command (not sure if it speeds up conversion, but it makes the binary lighter):
|
||||
|
||||
On Linux:
|
||||
```bash
|
||||
GOAMD64='v3' go build -a -v -ldflags="-s -w" -buildvcs=false
|
||||
```
|
||||
|
||||
On Windows (PowerShell):
|
||||
```ps
|
||||
$env:GOAMD64 = 'v3'; go build -a -v -ldflags="-s -w" -buildvcs=false
|
||||
```
|
||||
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
||||
module github.com/mojitaurelie/heic2jpg
|
||||
|
||||
go 1.20
|
||||
go 1.21
|
||||
|
||||
require github.com/adrium/goheif v0.0.0-20230113233934-ca402e77a786
|
||||
|
||||
|
||||
25
main.go
25
main.go
@@ -17,6 +17,18 @@ import (
|
||||
"github.com/mojitaurelie/heic2jpg/exif"
|
||||
)
|
||||
|
||||
const (
|
||||
VERSION = "0.1.0"
|
||||
|
||||
usageDescription = `heic2jpg - v%s.%s.%s.%s
|
||||
Note: <file> is ignored when -dir is set
|
||||
|
||||
Usage: heic2jpg [OPTIONS] <file>
|
||||
|
||||
OPTIONS:
|
||||
`
|
||||
)
|
||||
|
||||
type (
|
||||
filer interface {
|
||||
IsDir() bool
|
||||
@@ -25,11 +37,15 @@ type (
|
||||
)
|
||||
|
||||
func usage() {
|
||||
fmt.Printf("Usage: %s [OPTIONS] <file>\n\n", os.Args[0])
|
||||
fmt.Printf("Note: <file> is ignored when -dir is set\n\nOPTIONS:\n")
|
||||
fmt.Printf(usageDescription, VERSION, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
func version() {
|
||||
fmt.Printf("heic2jpg - v%s.%s.%s.%s\n", VERSION, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
go func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -48,8 +64,13 @@ func main() {
|
||||
removeOrig := flag.Bool("remove-original", false, "Remove the heic file after conversion")
|
||||
overwriteOut := flag.Bool("overwrite", false, "Overwrite file if already exists")
|
||||
outPath := flag.String("o", "", "Output directory")
|
||||
v := flag.Bool("v", false, "Show version")
|
||||
flag.Parse()
|
||||
|
||||
if *v {
|
||||
version()
|
||||
}
|
||||
|
||||
if *jpegQuality < 1 || *jpegQuality > 100 {
|
||||
fmt.Println("W: Illegal value for jpeg quality, quality is set to ", jpeg.DefaultQuality)
|
||||
*jpegQuality = jpeg.DefaultQuality
|
||||
|
||||
Reference in New Issue
Block a user