mirror of
https://github.com/gen2brain/cbconvert
synced 2025-10-14 10:38:51 +02:00
support thumbnails in file managers
This commit is contained in:
17
README.md
17
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.
|
It can convert one comic at a time or bulk convert comics to different formats to fit your various devices.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Features
|
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 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)
|
- [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:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
Using command line app
|
Using command line app
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
14
cbconvert.go
14
cbconvert.go
@@ -91,6 +91,7 @@ type Options struct {
|
|||||||
Suffix string // add suffix to file basename
|
Suffix string // add suffix to file basename
|
||||||
Cover bool // extract cover
|
Cover bool // extract cover
|
||||||
Thumbnail bool // extract cover thumbnail (freedesktop spec.)
|
Thumbnail bool // extract cover thumbnail (freedesktop spec.)
|
||||||
|
Outfile string // output file
|
||||||
Outdir string // output directory
|
Outdir string // output directory
|
||||||
Grayscale bool // convert images to grayscale (monochromatic)
|
Grayscale bool // convert images to grayscale (monochromatic)
|
||||||
Rotate int // Rotate images, valid values are 0, 90, 180, 270
|
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())
|
fmt.Fprintf(os.Stderr, "Error ReadImageBlob: %v\n", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
fileuri := "file://" + file
|
var fileuri string
|
||||||
filename := filepath.Join(c.Opts.Outdir, fmt.Sprintf("%x.png", md5.Sum([]byte(fileuri))))
|
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.SetImageFormat("PNG")
|
||||||
mw.SetImageProperty("Software", "CBconvert")
|
mw.SetImageProperty("Software", "CBconvert")
|
||||||
|
@@ -77,6 +77,7 @@ func parseFlags() (cbconvert.Options, []string) {
|
|||||||
|
|
||||||
thumbnail := kingpin.Command("thumbnail", "Extract cover thumbnail (freedesktop spec.)")
|
thumbnail := kingpin.Command("thumbnail", "Extract cover thumbnail (freedesktop spec.)")
|
||||||
thumbnail.Arg("args", "filename or directory").Required().ExistingFilesOrDirsVar(&args)
|
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("width", "Image width").Default(strconv.Itoa(0)).IntVar(&opts.Width)
|
||||||
thumbnail.Flag("height", "Image height").Default(strconv.Itoa(0)).IntVar(&opts.Height)
|
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)
|
thumbnail.Flag("fit", "Best fit for required width and height").BoolVar(&opts.Fit)
|
||||||
|
@@ -3,13 +3,13 @@
|
|||||||
{
|
{
|
||||||
"FileVersion": {
|
"FileVersion": {
|
||||||
"Major": 0,
|
"Major": 0,
|
||||||
"Minor": 5,
|
"Minor": 6,
|
||||||
"Patch": 0,
|
"Patch": 0,
|
||||||
"Build": 0
|
"Build": 0
|
||||||
},
|
},
|
||||||
"ProductVersion": {
|
"ProductVersion": {
|
||||||
"Major": 0,
|
"Major": 0,
|
||||||
"Minor": 5,
|
"Minor": 6,
|
||||||
"Patch": 0,
|
"Patch": 0,
|
||||||
"Build": 0
|
"Build": 0
|
||||||
},
|
},
|
||||||
@@ -24,14 +24,14 @@
|
|||||||
"Comments": "Comic Book converter",
|
"Comments": "Comic Book converter",
|
||||||
"CompanyName": "",
|
"CompanyName": "",
|
||||||
"FileDescription": "CBconvert CLI",
|
"FileDescription": "CBconvert CLI",
|
||||||
"FileVersion": "0.5.0",
|
"FileVersion": "0.6.0",
|
||||||
"InternalName": "",
|
"InternalName": "",
|
||||||
"LegalCopyright": "",
|
"LegalCopyright": "",
|
||||||
"LegalTrademarks": "",
|
"LegalTrademarks": "",
|
||||||
"OriginalFilename": "cbconvert.exe",
|
"OriginalFilename": "cbconvert.exe",
|
||||||
"PrivateBuild": "",
|
"PrivateBuild": "",
|
||||||
"ProductName": "CBconvert",
|
"ProductName": "CBconvert",
|
||||||
"ProductVersion": "0.5.0",
|
"ProductVersion": "0.6.0",
|
||||||
"SpecialBuild": ""
|
"SpecialBuild": ""
|
||||||
},
|
},
|
||||||
"VarFileInfo":
|
"VarFileInfo":
|
||||||
|
@@ -257,6 +257,7 @@ func (c *Comics) SetEnabled(b bool) {
|
|||||||
c.Root.ObjectByName("checkBoxNoRGB").Set("enabled", b)
|
c.Root.ObjectByName("checkBoxNoRGB").Set("enabled", b)
|
||||||
c.Root.ObjectByName("checkBoxConvertCover").Set("enabled", b)
|
c.Root.ObjectByName("checkBoxConvertCover").Set("enabled", b)
|
||||||
c.Root.ObjectByName("spinboxSize").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("sliderBrightness").Set("enabled", b)
|
||||||
c.Root.ObjectByName("sliderContrast").Set("enabled", b)
|
c.Root.ObjectByName("sliderContrast").Set("enabled", b)
|
||||||
c.Root.ObjectByName("checkBoxGrayscale").Set("enabled", b)
|
c.Root.ObjectByName("checkBoxGrayscale").Set("enabled", b)
|
||||||
|
@@ -3,13 +3,13 @@
|
|||||||
{
|
{
|
||||||
"FileVersion": {
|
"FileVersion": {
|
||||||
"Major": 0,
|
"Major": 0,
|
||||||
"Minor": 5,
|
"Minor": 6,
|
||||||
"Patch": 0,
|
"Patch": 0,
|
||||||
"Build": 0
|
"Build": 0
|
||||||
},
|
},
|
||||||
"ProductVersion": {
|
"ProductVersion": {
|
||||||
"Major": 0,
|
"Major": 0,
|
||||||
"Minor": 5,
|
"Minor": 6,
|
||||||
"Patch": 0,
|
"Patch": 0,
|
||||||
"Build": 0
|
"Build": 0
|
||||||
},
|
},
|
||||||
@@ -24,14 +24,14 @@
|
|||||||
"Comments": "Comic Book converter",
|
"Comments": "Comic Book converter",
|
||||||
"CompanyName": "",
|
"CompanyName": "",
|
||||||
"FileDescription": "CBconvert GUI",
|
"FileDescription": "CBconvert GUI",
|
||||||
"FileVersion": "0.5.0",
|
"FileVersion": "0.6.0",
|
||||||
"InternalName": "",
|
"InternalName": "",
|
||||||
"LegalCopyright": "",
|
"LegalCopyright": "",
|
||||||
"LegalTrademarks": "",
|
"LegalTrademarks": "",
|
||||||
"OriginalFilename": "cbconvert.exe",
|
"OriginalFilename": "cbconvert.exe",
|
||||||
"PrivateBuild": "",
|
"PrivateBuild": "",
|
||||||
"ProductName": "CBconvert",
|
"ProductName": "CBconvert",
|
||||||
"ProductVersion": "0.5.0",
|
"ProductVersion": "0.6.0",
|
||||||
"SpecialBuild": ""
|
"SpecialBuild": ""
|
||||||
},
|
},
|
||||||
"VarFileInfo":
|
"VarFileInfo":
|
||||||
|
Reference in New Issue
Block a user