Skip to content

Commit

Permalink
Can add EXIF tags to converted screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
CmdrVasquess committed Jan 1, 2024
1 parent a7f63a0 commit e5d483f
Show file tree
Hide file tree
Showing 43 changed files with 734 additions and 451 deletions.
2 changes: 1 addition & 1 deletion edeh/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ major=0
minor=6
patch=0
quality=a
build_no=115
build_no=137
2 changes: 1 addition & 1 deletion edeh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func mustFindDataDir() string {
func flags() {
flag.StringVar(&fJDir, "j", "",
"Manually set the directory with ED's journal files")
flag.StringVar(&fPluginPath, "p", "./plugin",
flag.StringVar(&fPluginPath, "p", "./plugins",
"Set plugin path")
flag.StringVar(&fData, "d", mustFindDataDir(), "Directory where data is stored")
flag.StringVar(&fPinOff, "off", "",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion edeh/plugin/recvplugin.go → edeh/plugins/recvplugin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package plugins

import (
"bufio"
Expand Down
File renamed without changes.
66 changes: 43 additions & 23 deletions edeh/plugin/screenshot/main.go → edeh/plugins/screenshot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,64 @@ package main

import (
"flag"
"fmt"
"log"
"log/slog"
"math"
"os"
"strconv"
"strings"

"github.com/CmdrVasquess/watched/edeh/plugin"
"github.com/CmdrVasquess/watched/edeh/plugins"
"github.com/CmdrVasquess/watched/examples/screenshot"
)

var (
scrns = screenshot.Screenshot{
EDPicDir: screenshot.DefaultPicsDir(),
OutRoot: ".",
Lat: math.NaN(), Lon: math.NaN(),
}
fAspect string
)

func flags() {
flag.Usage = func() {
w := flag.CommandLine.Output()
fmt.Fprintf(w, "Usage: %s [flags]\n", os.Args[0])
flag.PrintDefaults()
}

flag.StringVar(&scrns.EDPicDir, "p", scrns.EDPicDir,
"ED pictures directory")
flag.StringVar(&scrns.OutRoot, "d", scrns.OutRoot,
"Output directory for converted pictures")
flag.BoolVar(&scrns.CmdrDir, "cmdr", scrns.CmdrDir,
"Use commander-specific subdirectory in output directory")
flag.IntVar(&scrns.JpegQuality, "q", 90,
"Set JPEG output quality (1–100)")
flag.StringVar(&fAspect, "a", "",
"Set aspect ratio of output")
flag.BoolVar(&scrns.SubstOrig, "s", false,
"Put a converted substitue into ED pictures directory")
flag.BoolVar(&scrns.RmOrig, "rm", false,
"Remove original BMP after conversion")
flag.BoolVar(&scrns.AddTags, "tags", false,
"Add EXIF tags to JPEG output")
flag.Parse()
}

func main() {
flags()
log.Println("start edeh plugin 'screenshot'")
setAspect()
defer scrns.Close()
err := plugins.RunRecv(&scrns, nil, slog.Default())
if err != nil {
log.Fatal(err)
}
}

func setAspect() {
if fAspect == "" {
scrns.Aspect = 0
Expand All @@ -41,25 +83,3 @@ func setAspect() {
scrns.Aspect = w / h
}
}

func main() {
flag.StringVar(&scrns.EDPicDir, "p", scrns.EDPicDir,
"ED pictures directory")
flag.StringVar(&scrns.OutRoot, "d", scrns.OutRoot,
"Output directory for converted pictures")
flag.IntVar(&scrns.JpegQuality, "q", 90,
"Set JPEG output quality (1–100)")
flag.StringVar(&fAspect, "a", "",
"Set aspect ratio of output")
flag.BoolVar(&scrns.SubstOrig, "s", false,
"Put a converted substitue into ED ictures directory")
flag.BoolVar(&scrns.RmOrig, "rm", false,
"Remove original BMP after conversion")
flag.BoolVar(&scrns.AddTags, "tags", false,
"Add tags to JPEG output")
flag.Parse()
log.Println("start edeh plugin 'screenshot'")
setAspect()
defer scrns.Close()
plugin.RunRecv(&scrns, nil, slog.Default())
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
]
},
"status": {
"blacklist": ["*"]
"blacklist": ["*"],
"whitelist": ["Status"]
}
}
Binary file added edeh/plugins/screenshot/testdata/screenshot.bmp
Binary file not shown.
3 changes: 3 additions & 0 deletions edeh/plugins/screenshot/testdata/screenshot.jevt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Journal.xyz.log:1 { "timestamp":"2023-12-29T17:05:00Z", "event":"Commander", "FID":"F007", "Name":"J. Jameson" }
Status { "timestamp":"2023-12-31T14:42:40Z", "event":"Status", "Flags":2097152, "Latitude": 10, "Longitude": 20, "Altitude": 99 }
Journal.xyz.log:2 { "timestamp":"2023-12-29T17:05:19Z", "event":"Screenshot", "Filename":"\\ED_Pictures\\screenshot.bmp", "Width":5760, "Height":1080, "System":"Dehoae NH-R c6-1", "Body":"Dehoae NH-R c6-1" }
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions edeh/plugin/speak/main.go → edeh/plugins/speak/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"path/filepath"

"git.fractalqb.de/fractalqb/qblog"
plugin "github.com/CmdrVasquess/watched/edeh/plugin"
"github.com/CmdrVasquess/watched/edeh/plugins"
"github.com/CmdrVasquess/watched/examples/speak"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -42,7 +42,7 @@ func main() {
}
speaker.Verbose = speaker.Verbose || *fVerb
defer speaker.Close()
plugin.RunRecv(&speaker, nil, slog.Default())
plugins.RunRecv(&speaker, nil, slog.Default())
}

func logFatal(msg string, args ...any) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TTSExe: C:\bin\wsay.exe
TTSExe: C:\bin\wsay.exe # https://github.com/p-groarke/wsay
Args: []
Verbose: false
Events:
Expand All @@ -20,8 +20,6 @@ Events:
Template: >-
{{if and .NonBodyCount (gt .NonBodyCount 0.0) -}}
{{.NonBodyCount}} non-bodies
{{- else -}}
Boring system!
{{- end}}
FSSSignalDiscovered:
Flags: [-v, '2']
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion edeh/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const (
Minor = 6
Patch = 0
Quality = `a`
BuildNo = 115
BuildNo = 137
)
2 changes: 2 additions & 0 deletions edj/reputation.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package edj

const ReputationTag = "Reputation"

type Reputation struct {
Event
Empire, Federation, Independent, Alliance float64
Expand Down
20 changes: 20 additions & 0 deletions edj/screenshot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package edj

import (
"path/filepath"
"strings"
)

const ScreenshotTag = "Screenshot"

type Screenshot struct {
Event
Filename string
Width, Height int
System string
Body string
}

func (s *Screenshot) FilenameToOS() string {
return strings.ReplaceAll(s.Filename, "\\", string(filepath.Separator))
}
17 changes: 17 additions & 0 deletions eds/navroute.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package eds

import "github.com/CmdrVasquess/watched/edj"

const NavRouteTag = "NavRoute"

type NavRoute struct {
edj.Event
Route []NavSystem
}

type NavSystem struct {
StarSystem string
SystemAddress uint64
StarPos [3]float32
StarClass string
}
91 changes: 91 additions & 0 deletions eds/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package eds

import "github.com/CmdrVasquess/watched/edj"

const StatusTag = "Status"

type Status struct {
edj.Event
Flags StatusFlag
Pips [3]int8
Firegroup int
GuiFocus int
Fuel struct{ FuelMain, FuelReservoir float64 }
Cargo float64
// LegalState
Latitude float64
Longitude float64
Altitude int
Heading int
BodyName string
PlanetRadius float64
}

func (s *Status) AnyFlag(fs StatusFlag) bool {
return s.Flags&fs > 0
}

func (s *Status) AllFlags(fs StatusFlag) bool {
return s.Flags&fs == fs
}

type StatusFlag = uint32

// Read: https://forums.frontier.co.uk/forums/elite-api-and-tools/
const (
StatusDocked StatusFlag = (1 << iota)
StatusLanded
StatusGearDown
StatusShieldsUp
StatusSupercruise

StatusFAOff
StatusHPDeployed
StatusInWing
StatusLightsOn
StatusCSDeployed

StatusSilentRun
StatusFuelScooping
StatusSrvHandbrake
StatusSrvTurret
StatusSrvUnderShip

StatusSrvDriveAssist
StatusFsdMassLock
StatusFsdCharging
StatusCooldown
StatusLowFuel

StatusOverHeat
StatusHasLatLon
StatusIsInDanger
StatusInterdicted
StatusInMainShip

StatusInFighter
StatusInSrv
StatusHudAnalysis
StatusNightVis
StatusAltAvgR

StatusFSDJump
StatusSrvHighBeam
)

type GuiFocus = int

const (
StatusNoFocus GuiFocus = iota
StatusInternalPanel
StatusExternalPanel
StatusCommsPanel
StatusRolePanel
StatusStationServices
StatusGalaxyMap
StatusSystemMap
StatusOrrery
StatusFSSMode
StatusSAAMode
StatusCodex
)
1 change: 1 addition & 0 deletions examples/screenshot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/TestWriteJPEGFile.jpg
Loading

0 comments on commit e5d483f

Please sign in to comment.