Skip to content

Commit

Permalink
Thumbs: Improve thumbnail types and sizes report #4300
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mayer <michael@photoprism.app>
  • Loading branch information
lastzero committed May 29, 2024
1 parent c55da7f commit 9fef64c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
5 changes: 3 additions & 2 deletions internal/commands/show_file_formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (

// ShowFileFormatsCommand configures the command name, flags, and action.
var ShowFileFormatsCommand = cli.Command{
Name: "file-formats",
Usage: "Displays supported media and sidecar file formats",
Name: "file-formats",
Aliases: []string{"formats"},
Usage: "Displays supported media and sidecar file formats",
Flags: append(report.CliFlags, cli.BoolFlag{
Name: "short, s",
Usage: "hide format descriptions",
Expand Down
5 changes: 3 additions & 2 deletions internal/commands/show_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (

// ShowMetadataCommand configures the command name, flags, and action.
var ShowMetadataCommand = cli.Command{
Name: "metadata",
Usage: "Displays supported metadata tags and standards",
Name: "metadata",
Aliases: []string{"meta"},
Usage: "Displays supported metadata tags and standards",
Flags: append(report.CliFlags, cli.BoolFlag{
Name: "short, s",
Usage: "hide links to documentation",
Expand Down
9 changes: 5 additions & 4 deletions internal/commands/show_thumb_sizes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (

// ShowThumbSizesCommand configures the command name, flags, and action.
var ShowThumbSizesCommand = cli.Command{
Name: "thumb-sizes",
Usage: "Displays supported standard thumbnail sizes",
Flags: report.CliFlags,
Action: showThumbSizesAction,
Name: "thumb-sizes",
Aliases: []string{"thumbs"},
Usage: "Displays supported thumbnail types and sizes",
Flags: report.CliFlags,
Action: showThumbSizesAction,
}

// showThumbSizesAction displays supported standard thumbnail sizes.
Expand Down
14 changes: 12 additions & 2 deletions internal/thumb/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func Report(sizes SizeList, short bool) (rows [][]string, cols []string) {
if short {
cols = []string{"Size", "Usage"}
} else {
cols = []string{"Name", "Width", "Height", "Aspect Ratio", "Usage"}
cols = []string{"Name", "Width", "Height", "Aspect Ratio", "Available", "Usage"}
}

sorted := append(SizeList{}, sizes...)
Expand All @@ -31,7 +31,17 @@ func Report(sizes SizeList, short bool) (rows [][]string, cols []string) {
if short {
rows = append(rows, []string{fmt.Sprintf("%d", s.Width), s.Usage})
} else {
rows = append(rows, []string{s.Name.String(), fmt.Sprintf("%d", s.Width), fmt.Sprintf("%d", s.Height), report.Bool(s.Fit, "Preserved", "1:1"), s.Usage})
aspectRatio := report.Bool(s.Fit, "Preserved", "1:1")

available := "On-Demand"

if s.Required {
available = "Always"
} else if s.Optional {
available = "Optional"
}

rows = append(rows, []string{s.Name.String(), fmt.Sprintf("%d", s.Width), fmt.Sprintf("%d", s.Height), aspectRatio, available, s.Usage})
}
}

Expand Down

0 comments on commit 9fef64c

Please sign in to comment.