-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (73 loc) · 2.46 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"flag"
"fmt"
"os"
"runtime"
)
var verbose = flag.Bool("verbose", false, "Verbose tracing")
var fullscreen = flag.Bool("fullscreen", false, "Fullscreen display")
var fit = flag.Bool("fit", false, "Scale images to fit window")
var maxPreload = flag.Int("preload", 10, "Maximum images to concurrently load")
var width = flag.Int("width", 1200, "Window width") // These are fyne sizes, not pixels
var height = flag.Int("height", 1000, "Window height")
var sidecar = flag.Bool("sidecar", false, "Use sidecar file for EXIF")
func main() {
flag.Usage = usage
flag.Parse()
var f []string
// No args, do all image files in the current directory
if len(flag.Args()) == 0 {
f = expand([]string{"*.jpg", "*.jpeg", "*.tif", "*.tiff"})
} else {
f = expand(flag.Args())
}
// Limit the max preload count to the number of CPUs
preload := runtime.NumCPU()
if preload > *maxPreload {
preload = *maxPreload
}
if len(f) == 0 {
fmt.Printf("No files to display")
return
}
if *verbose {
fmt.Printf("%d files in total, preload = %d\n", len(f), preload)
}
initExif()
a, err := newPtag(*width, *height, preload)
if err != nil {
fmt.Fprintf(os.Stderr, "init: %v", err)
return
}
a.start(f)
}
func usage() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, `
Shortcut keys are:
'N' <right-arrow> <space> Next image
'P' <left-arrow> <back-space> Previous image
<Home> First image
<End> Last image
<down-arrow> Jump forward 10 images
<up-arrow> Jump back 10 images
-, 0, 1, 2, 3, 4, 5 Set the EXIF rating to this value [- delete]
'F' Toggle full-screen
'R' Rotate right 90 degrees
'M' Mirror flip the image
'Q' Quit
`)
}