Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle

Notices

Reply
 
Thread Tools Search this Thread
Old 11-20-2012, 10:58 AM   #1
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 71,406
Karma: 305065800
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
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.]
Attached Files
File Type: zip kindlecover.pyw.zip (7.1 KB, 524 views)
File Type: zip KindleCover 1.0.2.app.zip (459.4 KB, 533 views)

Last edited by pdurrant; 11-23-2012 at 06:56 AM.
pdurrant is offline   Reply With Quote
Old 11-21-2012, 05:40 PM   #2
alansplace
Grand Sorcerer
alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.alansplace ought to be getting tired of karma fortunes by now.
 
alansplace's Avatar
 
Posts: 5,883
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
Cool hmmm...

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.
alansplace is offline   Reply With Quote
Old 11-21-2012, 06:14 PM   #3
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 71,406
Karma: 305065800
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
Quote:
Originally Posted by alansplace View Post
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?
Alf is welcome to include it in the tools, but since it doesn't affect DRM (& isn't affected by DRM*) it can be hosted here at mobileread.

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.
pdurrant is offline   Reply With Quote
Old 11-21-2012, 07:17 PM   #4
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,477
Karma: 26012492
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.
NiLuJe is offline   Reply With Quote
Old 11-23-2012, 06:58 AM   #5
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 71,406
Karma: 305065800
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
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.
pdurrant is offline   Reply With Quote
Old 12-02-2012, 05:50 AM   #6
Fluribus
Guru
Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.Fluribus ought to be getting tired of karma fortunes by now.
 
Fluribus's Avatar
 
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.)
Fluribus is offline   Reply With Quote
Old 12-02-2012, 07:14 AM   #7
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 71,406
Karma: 305065800
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
Quote:
Originally Posted by Fluribus View Post
The python script seems to work quite well with Python 2.7.3. It didn't work with 3.3.0.
Yes, it's written for python 2.5 and later. While Python 3 is certainly the python of the future, the python of the present seems to be 2.x
pdurrant is offline   Reply With Quote
Reply

Tags
kindle tools, mobi2mobi

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ePub Zip/Unzip AppleScript application for Mac OS X pdurrant ePub 145 03-08-2023 04:47 AM
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


All times are GMT -4. The time now is 03:26 PM.


MobileRead.com is a privately owned, operated and funded community.