AddKindleMediaQueries
A Sigil Plugin
Optimally formats all epub images both for KF7 devices(in pixels) and KF8 devices(as a %)
Requirements
Plugin Type: Edit
Minimum Sigil requirement: v0.9.3 or higher
Python Requirements: Python 3.4+ (Bundled or External)
OS Requirements: Windows, Linux or OSX
Current Version: "0.1.0"
*** Tested on Windows 7, 8 & 10 only ***
Installation
* Select Manage Plugins from the Plugins menu. In the dialog box, select either the Bundled Python or the External Python(Python 3.4+ should be installed on your computer to run this plugin externally).
* Click Add Plugin and select AddKindleMediaQueries_vXXX.zip. This will load and install the plugin into Sigil, which you can then select and run the plugin by selecting Plugins > Edit > AddKindleMediaQueries
Description
This simple plugin is an edit plugin that automatically dual formats all ebook image entries in your epub and also adds the appropriate media queries to the main stylesheet for optimal and proper rendering of all images on both KF7 devices(in pixels) and KF8 devices(as percentages). At runtime on Kindle ereaders the media queries in the CSS will then select the appropriate image line to display according to whether your ebook is running on a Kindle KF7 device or KF8 device.
User Options(via dialog):
*Add media queries to this stylesheet
This is an option dropdown list that allows you to select the right stylesheet from your epub to add the media queries. The stylesheet that you choose should be the main stylesheet that is used to style all text files and images in your epub.
* Type preferred base pixel width value
This text entry option allows you to type in your own preferred base width value in pixels for the % calculation. This value is used to calculate the percentage width of the images for KF8 devices only. The calculation is shown below.
image-width-in-pixels/630 x 100
The 630px value is the default base width option(or default screen width option). So the user has the option of either typing in a larger or smaller base width value for all ebook images or the user can just use the default -- 630px.If you are unsure about how to use this option then you should just use the default base pixel width value.
Plugin Run
First load your epub into Sigil and then just run this plugin.
Please also be aware that the above percentage calculation for all Kindle KF8 image dimensions will not be exact but will instead be a best-average or ballpark percentage width because I've only used a single, default base width value(average screen width value) for all Kindle KF8 devices in my percentage calculation above. This will inevitably give small variances in displayed image size across the many different KF8 devices and legacy KF8s(with slightly different screen widths) because I have only used a single, best-average screen width value for all calculations.
But if you want your percentage images to be exactly correct on one particular KF8 device then this is possible. All you have to do is enter the proper screen width value of that KF8 device(in pixels) as your preferred base width value option in the user dialog and an accurate or exact percentage value will be calculated for all displayed images for that one particular KF8 device only.