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

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 08-18-2017, 05:22 AM   #1
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 413
Karma: 768286
Join Date: May 2013
Location: Philippines
Device: Android S5
[Plugin] AddKindleMediaQueries

Optimally dual-formats all epub image entries both for KF7 devices(in pixels) and KF8 devices(as a %)

Requirements
Plugin Type: Edit
MIT Licence(OSI)
Minimum Sigil requirement: v0.9.3 or higher
Python Requirements: Python 3.4+ (Bundled or External)
OS Requirements: Windows, Linux or OSX
*** Tested on Windows 7, 8 & 10 only ***
Current Version: "0.1.8"

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 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.

This plugin will now automatically dual format svg images for Kindle epubs. KF8 ebook images will be displayed in svg format whereas KF7 ebook images will be added and displayed in html style using pixel values.See Caveat below.(added in v0.1.8)

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 which allows the user to increase or decrease the dimensions of 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.

Caveat
Concening the dual formatting of svg images, I found that bs4 automatically converts all svg camel case attributes to lower case causing epub errors. I tried using the "xml" parser with bs4 to correct this problem but doing that gave me an even bigger mess. So I simply wrote a function that converted all the relevant svg attributes back to camel case which will also tend to limit your use of svg attributes in svg code because I've used Sigil's svg cover template(attributes) as my reference for converting ebook images to svg. So if you are using other camel case attributes in your svg code that are not included in Sigil's svg cover template then be warned that doing so will probably cause svg formatting errors with 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.

Updates
* The plugin can now handle all forms of div with image tag formatting(changed in v0.1.5)

Changes
Spoiler:

v0.1.8
-- This plugin will now automatically dual format svg images for Kindle epubs. KF8 ebook images will be displayed in svg format whereas KF7 ebook images will be added and displayed using pixel values.
-- Improved logging
v0.1.7
-- Added MIT SW Licence
v0.1.6
-- Fixed bug causing SVG errors. You can now load an epub containing SVG image wrappers and there should be no Epubcheck errors.
v0.1.5
-- The plugin can now handle all forms of div with image tag formatting
v0.1.4
-- Fixed a bug causing lower case font name errors and duplication errors in the css and the html repectively. Thanks to Doitsu.
v0.1.3
-- Initial release
Attached Thumbnails
Click image for larger version

Name:	User_Options.JPG
Views:	113
Size:	23.2 KB
ID:	163063  
Attached Files
File Type: zip AddKindleMediaQueries_v018.zip (45.9 KB, 104 views)

Last edited by slowsmile; 06-17-2018 at 11:44 PM.
slowsmile is offline   Reply With Quote
Old 08-26-2017, 09:19 AM   #2
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 413
Karma: 768286
Join Date: May 2013
Location: Philippines
Device: Android S5
Updates

* Having SVG image wrappers in your epub will no longer cause Epubcheck errors after running this plugin.(changed in v0.1.6)

* The plugin can now handle all forms of div with image tag formatting(changed in v0.1.5)
slowsmile is offline   Reply With Quote
Old 08-26-2017, 10:11 AM   #3
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 52,383
Karma: 47516399
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, Sony PRS-650, Sony PRS-T1, nook STR, iPad 4, iPhone 5
You you use an SVG image wrapper, are you specifying the exact resolution for the images in the SVG wrapper? If not, that can cause a display issue.
JSWolf is offline   Reply With Quote
Old 08-26-2017, 05:44 PM   #4
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 413
Karma: 768286
Join Date: May 2013
Location: Philippines
Device: Android S5
@JSWolf...The above update simply means that if you have any SVG image wrappers in your epub then, after using the plugin, this would cause SVG errors on Epubcheck. With the above update, this bug has been fixed. The plugin should only dual format ordinary html images only -- it will not dual format svg image wrappers.
slowsmile is offline   Reply With Quote
Old 06-15-2018, 12:17 AM   #5
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 413
Karma: 768286
Join Date: May 2013
Location: Philippines
Device: Android S5
Update: The following changes have been made to the plugin in v0.1.8:

* The plugin will now automatically dual format svg images for Kindle epubs. KF8 ebook images will be displayed in svg format whereas KF7 ebook images will be added and displayed in html style using simple pixel values.

* Improved logging

Last edited by slowsmile; 06-15-2018 at 12:32 AM.
slowsmile is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FileType Plugin] YVES Bible Plugin ClashTheBunny Plugins 24 07-21-2018 10:11 AM
Problem with my ScrambleEbook plugin and the Plugin Updater tool jackie_w Development 14 01-19-2017 10:49 PM
Plugin not customizable: Plugin: HTML Output does not need customization flyingfoxlee Conversion 2 02-24-2012 02:24 AM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 12:27 PM
New Plugin Type Idea: Library Plugin cgranade Plugins 3 09-15-2010 12:11 PM


All times are GMT -4. The time now is 08:39 AM.


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