Hey,
I store a lot of my books on my laptop with the mobi format, because I generally send that file to my kindle so I can read it there. But it's annoying that Gnome's default file browser, Nautilus, doesn't have the ability to generate thumbnails for mobi files. It can do it for PDF files(using evince-thumbnailer), but not for mobi. It's fairly simple to write your own, so here's what I did.
To extract the cover from a mobi file, I use ebook-meta
ebook-meta Book.mobi --get-cover=thumbnail.png
But ebook-meta doesn't give you a way to resize the output image, so we'll need to use convert for that
convert cover.jpg -resize x"$size" "$output_image"
This makes the image's height $size pixels, without messing up the aspect ratio.
Combining this into a shell script gives
#!/bin/bash if [ $# -ne 3 ]; then echo "Usage: $0 <input_image> <size> <output_image>" exit 1 fi input_image="$1" size="$2" output_image="$3" ebook-meta "$input_image" --get-cover=/tmp/cover.jpg convert /tmp/cover.jpg -resize x"$size" "$output_image" rm -f /tmp/cover.jpg
Save this in /usr/local/bin as ebook_thumbnailer.sh, or any other name.
This extracts the cover image from the mobi file into /tmp/cover.jpg, and then resizes it to the size passed in the arguments.
Now to integrate this with Nautilus.
Go to /usr/share/thumbnailers and create a file called ebook.thumbnailer
Open it with sudoedit and paste this
[Thumbnailer Entry]
TryExec=/usr/local/bin/ebook_thumbnailer.sh
Exec=/usr/local/bin/ebook_thumbnailer.sh %i %s %o
MimeType=application/x-mobipocket-ebook;image/vnd.djvu+multipage;
For an explanation of the different fields, check out this.
Now kill all running instances of nautilus with killall nautilus, and delete failed thumbnails with rm -r ~/.cache/thumbnails/fail, and you should be good to go.