![]() |
#1 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,618
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
KindleCover: AppleScript wrapper and Python script application
I like having pretty covers on my Kindle/Mobipocket books. They are displayed by some of my reading devices, and they also show up on my Mac, thanks to my QuickLook plugin.
But changing covers on a Mobipocket/Kindle book isn't easy. At least, it's not easy without doing a conversion in calibre, which also re-works all the text coding and metadata of the book. Now, I've been playing around with the Kindle/Mobipocket file structure for quite a while (e.g. MobiUnpack) so I decided to write a special purpose cover replacement script. It only replaces the cover image and/or thumbnail image in the file. It changes nothing else. So, for Mac users, I've also written an AppleScript wrapper. (The python script is embedded, so Mac users only need to download the AppleScript.) Drag a Kindle/Mobipocket file onto the AppleScript wrapper. A dialog pops up asking you to select an image. Then the new file is created in the same folder as the old file. It's just the same, but with a new cover image, AND a new thumbnail image. The AppleScript creates a 240 pixel thumbnail image from the cover image automatically, and inserts it into the file along with the cover image. For non-Mac users, the script now includes a tkInter interface, allowing original file, cover image, thumbnail image and output file to be chosen simply. This script only works with newer Mobipocket files with an EXTH section and metadata identifying the cover and thumbnail images. (All Amazon Kindle Mobipocket format books are like this, and yes, this script does work with the new Amazon KF8/AZW3 format ebooks.) Amazon recommend that images be below 127KiB (which this script enforces). I'd recommend pixel dimensions of at least 800 tall, and 1024 might be better. I'd love to get feedback on the AppleScript or the python script. [Edit: 1.02 now includes a tkInter interface, and works on Windows with files with unicode files names.] Last edited by pdurrant; 11-23-2012 at 06:56 AM. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,895
Karma: 464403178
Join Date: Feb 2010
Location: 33.9388° N, 117.2716° W
Device: Kindles K-2, K-KB, PW 1 & 2, Voyage, Fire 2, 5 & HD 8, Surface 3, iPad
|
![]()
Nice, a cool enhancement to the windows version would be a windows interface for inputting the values needed (a .pyw I think?).
Also, I never knew that a mobi had an imbedded thumbnail. What do you get if you don't give it a new thumbhail. My test mobi looked perfectly normal in Kindlepreviewer and I just omitted the -t switch from the command line when I tested it? What size should the thumbnail be? Will this be included in future tools updates? ![]() Last edited by alansplace; 11-21-2012 at 05:42 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,618
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Quote:
I suspect that most modern Mobipocket readers ignore the thumbnail image. It 'ought' to have a maximum dimension of 240 pixels. Yes, it would be possible to add a tk interface to the script, but I don't have much incentive, since I much prefer using my Mac. But if someone else wants to have ago, that would be great. [EDIT: I added one in version 1.0.2] I suppose it would be possible to add in (some of) the Python Imaging Library and have the thumbnail generation done by the python script, making it easier to use cross-platform. And for that manner, some sanity-checking of the cover image dimensions and file size would be beneficial. Perhaps others will be inspired to contribute. *That is, it's possible to replace the cover on a DRMed Kindle/Mobipocket file without first stripping the DRM, and the DRMed file will work fine afterwards with the device it's intended for. Last edited by pdurrant; 02-09-2013 at 11:24 AM. |
|
![]() |
![]() |
![]() |
#4 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
AFAIK, the embedded thumbnail is only used (at least, I'm not familiar with K 4 iOS/Android/PC/OSX) on the Touch/PW in Cover View mode, and even then, in some very specific cases only:
* On the Touch (with JBPatch): When the ASIN (exth 113) is unset or invalid (an UUID). * On the PW: When the ASIN (exth 113) is unset. Otherwise, the firmware falls back to the sideloaded thumbnail (or downloads it from Amazon if the ASIN is valid). (And, yeah, 240x240 seems to be the 'standard', at least that's what both KG & Calibre do. Fun detail: It's actually a tiny bit too small for the PW screen, making those easy to spot). Last edited by NiLuJe; 11-21-2012 at 07:23 PM. |
![]() |
![]() |
![]() |
#5 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,618
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Just updated to 1.0.2.
Fixed problems with unicode files names on Windows. Added a tkInter interface. Sanity-check of image files sizes is now 127KiB as Amazon recommend. Image file types now restricted to GIF and JPEG as Amazon recommend. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 891
Karma: 8893661
Join Date: Feb 2012
Device: Kindle
|
The python script seems to work quite well with Python 2.7.3. It didn't work with 3.3.0.
I wish that Kindle files were as easy to tweak as EPUB rather than hermetically sealed and kept in mayonnaise jars on Funk & Wagnalls porch. (I don't know if Johnny Carson was ever broadcast outside the US. I thought about doing a Monty Python joke but decided to do something completely different.) |
![]() |
![]() |
![]() |
#7 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,618
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
|
![]() |
![]() |
![]() |
Tags |
kindle tools, mobi2mobi |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ePub Zip/Unzip AppleScript application for Mac OS X | pdurrant | ePub | 149 | 12-02-2024 12:51 PM |
Applescript Wrapper Application for Kindlegen | pdurrant | Kindle Formats | 50 | 02-18-2020 01:16 AM |
Kindlestrip Python script and AppleScript wrapper | pdurrant | Kindle Formats | 137 | 08-15-2017 01:16 AM |
KindleNamer: Kindle/Mobi File Naming AppleScript/Python Script | pdurrant | Kindle Formats | 1 | 11-22-2012 06:23 AM |
Nedd a little help with a python script | gandor62 | Calibre | 1 | 08-07-2008 09:59 PM |