From 2c5bc9e21d40ec37f4e2914b02e9c1efee12968b Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Fri, 22 Jan 2016 17:17:43 +0100 Subject: [PATCH] support thumbnails in file managers --- README.md | 17 +++++++++++++++++ cbconvert.go | 14 ++++++++++++-- cmd/main.go | 1 + cmd/versioninfo.json | 8 ++++---- gui/main.go | 1 + gui/versioninfo.json | 8 ++++---- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a364e66..4658dbb 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ CBconvert is a [Comic Book](http://en.wikipedia.org/wiki/Comic_Book_Archive_file It can convert one comic at a time or bulk convert comics to different formats to fit your various devices. +![screenshot](http://cbconvert.com/screenshot.png) + Features -------- @@ -28,6 +30,21 @@ Download - [Linux 64bit GUI](https://github.com/gen2brain/cbconvert/releases/download/0.5.0/cbconvert-0.5.tar.gz) - [Linux 64bit CMD](https://github.com/gen2brain/cbconvert/releases/download/0.5.0/cbconvert-cmd-0.5.tar.gz) +Using cbconvert in file managers to generate freedesktop thumbnails +------------------------------------------------------------------- + +Just copy cbconvert cmd binary to your PATH and create file ~/.local/share/thumbnailers/cbconvert.thumbnailer : + + [Thumbnailer Entry] + TryExec=cbconvert + Exec=cbconvert thumbnail --quiet --width %s --outfile %o %i + MimeType=application/pdf;application/x-pdf;image/pdf;application/x-cbz;application/x-cbr;application/x-cb7;application/x-cbt;application/oxps;application/vnd.ms-xpsdocument;application/epub+zip; + +This is how it looks like in PCManFM file manager: + +![thumbnails](http://cbconvert.com/thumbnails.png) + + Using command line app ---------------------- diff --git a/cbconvert.go b/cbconvert.go index eeba03c..32a42b7 100644 --- a/cbconvert.go +++ b/cbconvert.go @@ -91,6 +91,7 @@ type Options struct { Suffix string // add suffix to file basename Cover bool // extract cover Thumbnail bool // extract cover thumbnail (freedesktop spec.) + Outfile string // output file Outdir string // output directory Grayscale bool // convert images to grayscale (monochromatic) Rotate int // Rotate images, valid values are 0, 90, 180, 270 @@ -998,8 +999,17 @@ func (c *Convertor) ExtractThumbnail(file string, info os.FileInfo) { fmt.Fprintf(os.Stderr, "Error ReadImageBlob: %v\n", err.Error()) } - fileuri := "file://" + file - filename := filepath.Join(c.Opts.Outdir, fmt.Sprintf("%x.png", md5.Sum([]byte(fileuri)))) + var fileuri string + var filename string + + if c.Opts.Outfile == "" { + fileuri = "file://" + file + filename = filepath.Join(c.Opts.Outdir, fmt.Sprintf("%x.png", md5.Sum([]byte(fileuri)))) + } else { + abs, _ := filepath.Abs(c.Opts.Outfile) + fileuri = "file://" + abs + filename = abs + } mw.SetImageFormat("PNG") mw.SetImageProperty("Software", "CBconvert") diff --git a/cmd/main.go b/cmd/main.go index e96a8e4..f784f50 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -77,6 +77,7 @@ func parseFlags() (cbconvert.Options, []string) { thumbnail := kingpin.Command("thumbnail", "Extract cover thumbnail (freedesktop spec.)") thumbnail.Arg("args", "filename or directory").Required().ExistingFilesOrDirsVar(&args) + thumbnail.Flag("outfile", "Output file").Default("").StringVar(&opts.Outfile) thumbnail.Flag("width", "Image width").Default(strconv.Itoa(0)).IntVar(&opts.Width) thumbnail.Flag("height", "Image height").Default(strconv.Itoa(0)).IntVar(&opts.Height) thumbnail.Flag("fit", "Best fit for required width and height").BoolVar(&opts.Fit) diff --git a/cmd/versioninfo.json b/cmd/versioninfo.json index 6d757fa..6caf6be 100644 --- a/cmd/versioninfo.json +++ b/cmd/versioninfo.json @@ -3,13 +3,13 @@ { "FileVersion": { "Major": 0, - "Minor": 5, + "Minor": 6, "Patch": 0, "Build": 0 }, "ProductVersion": { "Major": 0, - "Minor": 5, + "Minor": 6, "Patch": 0, "Build": 0 }, @@ -24,14 +24,14 @@ "Comments": "Comic Book converter", "CompanyName": "", "FileDescription": "CBconvert CLI", - "FileVersion": "0.5.0", + "FileVersion": "0.6.0", "InternalName": "", "LegalCopyright": "", "LegalTrademarks": "", "OriginalFilename": "cbconvert.exe", "PrivateBuild": "", "ProductName": "CBconvert", - "ProductVersion": "0.5.0", + "ProductVersion": "0.6.0", "SpecialBuild": "" }, "VarFileInfo": diff --git a/gui/main.go b/gui/main.go index 5253979..0d87e52 100644 --- a/gui/main.go +++ b/gui/main.go @@ -257,6 +257,7 @@ func (c *Comics) SetEnabled(b bool) { c.Root.ObjectByName("checkBoxNoRGB").Set("enabled", b) c.Root.ObjectByName("checkBoxConvertCover").Set("enabled", b) c.Root.ObjectByName("spinboxSize").Set("enabled", b) + c.Root.ObjectByName("buttonLevels").Set("enabled", b) c.Root.ObjectByName("sliderBrightness").Set("enabled", b) c.Root.ObjectByName("sliderContrast").Set("enabled", b) c.Root.ObjectByName("checkBoxGrayscale").Set("enabled", b) diff --git a/gui/versioninfo.json b/gui/versioninfo.json index ca5454c..963e671 100644 --- a/gui/versioninfo.json +++ b/gui/versioninfo.json @@ -3,13 +3,13 @@ { "FileVersion": { "Major": 0, - "Minor": 5, + "Minor": 6, "Patch": 0, "Build": 0 }, "ProductVersion": { "Major": 0, - "Minor": 5, + "Minor": 6, "Patch": 0, "Build": 0 }, @@ -24,14 +24,14 @@ "Comments": "Comic Book converter", "CompanyName": "", "FileDescription": "CBconvert GUI", - "FileVersion": "0.5.0", + "FileVersion": "0.6.0", "InternalName": "", "LegalCopyright": "", "LegalTrademarks": "", "OriginalFilename": "cbconvert.exe", "PrivateBuild": "", "ProductName": "CBconvert", - "ProductVersion": "0.5.0", + "ProductVersion": "0.6.0", "SpecialBuild": "" }, "VarFileInfo":