Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-01-2015, 01:50 AM   #1
gezginrocker
Member
gezginrocker began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2015
Device: Kindle
Wrap in SVG plugin?

Hi,

Currently I'm using "Add Cover" tool to wrap my images in SVG. But it is quite a work doing all images one by one. It would be very nice if there was a plugin which allows us to right click an image and choose option "Wrap in SVG", as discussed here: https://www.mobileread.com/forums/arc.../t-215664.html

Thanks
gezginrocker is offline   Reply With Quote
Old 02-01-2015, 03:11 AM   #2
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
I am actually thinking about that, but I think that the plugin system is not fit for that.
Toxaris is offline   Reply With Quote
Advert
Old 02-01-2015, 09:01 AM   #3
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by Toxaris View Post
I am actually thinking about that, but I think that the plugin system is not fit for that.
The plugin system as designed would not work for this situation. It was designed with separation from the GUI from the get go in mind. This way 1) Plugins are not tied specifically to Sigil (some plugins are dual calibre and sigil plugins for example). 2) Licensing, by having an API and separation plugin authors can choose any license (even commercial) for their plugins.

These choices do limit what plugins can do. But something like this might not be a bad idea for including as part of Sigil itself.

My gut feeling (not really having looking into this much) is a clip that uses a regex to wrap an image in SVG would be the best way to go. It might be a good example clip for us to add.
user_none is offline   Reply With Quote
Old 02-01-2015, 10:07 AM   #4
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Quote:
Originally Posted by user_none View Post
The plugin system as designed would not work for this situation. It was designed with separation from the GUI from the get go in mind. This way 1) Plugins are not tied specifically to Sigil (some plugins are dual calibre and sigil plugins for example). 2) Licensing, by having an API and separation plugin authors can choose any license (even commercial) for their plugins.

These choices do limit what plugins can do. But something like this might not be a bad idea for including as part of Sigil itself.

My gut feeling (not really having looking into this much) is a clip that uses a regex to wrap an image in SVG would be the best way to go. It might be a good example clip for us to add.
That is what I thought.

The issue with a regex or clip, is that the dimensions of the image must be adjusted based on the actual image. That cannot be retrieved by a regex or clip.
Toxaris is offline   Reply With Quote
Old 02-01-2015, 10:09 AM   #5
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by Toxaris View Post
That is what I thought.

The issue with a regex or clip, is that the dimensions of the image must be adjusted based on the actual image. That cannot be retrieved by a regex or clip.
You are correct, the actual dimensions cannot be pulled but most of the time I've noticed people use a set dimension for SVG images because they use a high quality image and want it scaled down. So in that sense a clip would work.

* SVG wrapped images I should say
user_none is offline   Reply With Quote
Advert
Old 02-01-2015, 10:24 AM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,809
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by gezginrocker View Post
Hi,

Currently I'm using "Add Cover" tool to wrap my images in SVG. But it is quite a work doing all images one by one. It would be very nice if there was a plugin which allows us to right click an image and choose option "Wrap in SVG", as discussed here: https://www.mobileread.com/forums/arc.../t-215664.html

Thanks
+1
I currently 'walk' a cover leaving behind SVG wrapped IMG code. It is tedious deleting the 2 symantics so I could do the next cover

Maybe a change to "Tools:Add Cover' to Tools:Wrap SVG which has a tick Make this the Cover (which does the current 3 additional steps:1) moves from current filelist insert location to first file, 2)IMG semantic set to 'cover', 3)file semantic set to 'cover'
theducks is offline   Reply With Quote
Old 02-01-2015, 10:51 AM   #7
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi,

Actually, you could do something like this in a plugin as well. You just could not tie it to the right click menu. Instead you would invoke an SVGImgWrapper edit plugin which pop up a gui list of all of the images it finds in the book, and you simply check which ones (or all) you want to wrap. It would then walk all of the html files and applying the wrapping where needed. Not as nice as your right click approach but doable I think, unless I am missing something.

KevinH
KevinH is offline   Reply With Quote
Old 02-04-2015, 06:13 AM   #8
gezginrocker
Member
gezginrocker began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2015
Device: Kindle
I agree, it doesn't have to be right click. Just some less hassle way to wrap images in SVG.
gezginrocker is offline   Reply With Quote
Old 04-10-2015, 03:04 AM   #9
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
Quote:
Originally Posted by theducks View Post
+1
I currently 'walk' a cover leaving behind SVG wrapped IMG code. It is tedious deleting the 2 symantics so I could do the next cover

Maybe a change to "Tools:Add Cover' to Tools:Wrap SVG which has a tick Make this the Cover (which does the current 3 additional steps:1) moves from current filelist insert location to first file, 2)IMG semantic set to 'cover', 3)file semantic set to 'cover'
Yes, just expanding the functionality a little.
Or, adding it as an option under "Insert": "insert image as SVG".
In fact, "Add a a cover" would also be better under that head than the grab-bag "Tools" heading.

For a while I was adding full-page images by "adding a cover" and then found it overwrote the "real" cover file and tagged the new image as the cover. (I wasn't aware of the semantic tags until then.)

So it ended up being less hassle to just do it by hand than clean up the mess.
AlanHK is offline   Reply With Quote
Old 04-10-2015, 11:40 AM   #10
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi,

If you want this feature any time soon, I would suggest a python plugin. If you can show me the before and after html, I can create a plugin that will wrap all images with the desired svg code and not have it add a cover semantics.

KevinH
KevinH is offline   Reply With Quote
Old 04-18-2015, 10:21 AM   #11
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
rubeus has developed a more advanced version that you can download here. Please download his version unless you're using an older Sigil version and/or Python 2.7.x.

With the help of KevinH, who gave me some extremely helpful pointers, I've created a very simple proof-of-concept plugin that duplicates the functionality of Tools > Add Cover but doesn't touch the existing cover or the guide section.

Usage:

1. Install the plugin as usual.
2. Select Plugins > Edit > SVGWrapper > Start.
3. Click the arrow of the dropdown box, select an image and click Insert.
4. Repeat step 3 until you've added all the desired images.
5. Click Done to close the Insert Image dialog box and OK to close the Plugin Runner dialog box.

Known issues:

1. The Book Browser won't be updated if you click the Insert button, but the plugin will write a xxx.xhtml added message to the Plugin Runner window. (The Book Browser will be updated when you click Done.)
2. You can't select the location or the name of added images. (Each image will be added at the beginning of the book using the image name as the file name.)

Credits:

This plugin uses code originally developed by the KindleUnpack developers.
Attached Thumbnails
Click image for larger version

Name:	svgwrapper.png
Views:	626
Size:	2.5 KB
ID:	137390  
Attached Files
File Type: zip SVGWrapper_v0.1.2.zip (10.0 KB, 545 views)

Last edited by Doitsu; 12-21-2015 at 05:26 AM. Reason: Uplodaded Python 3 & Sigil 0.8.9 compatible version
Doitsu is offline   Reply With Quote
Old 04-18-2015, 10:54 AM   #12
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Cool! Good work.

I know it was probably easiest when re-using the KindleUnpack code, but keep in mind that most of the functions provided by utf8_utils.py and path.py are already available in the plugin framework via "compatibility_utils.py" and "unipath.py" respectively.

No need to root them out and change them in this case since they just work, but something to keep in mind for the future.
DiapDealer is offline   Reply With Quote
Old 04-18-2015, 12:04 PM   #13
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi Doitsu,
Nicely done!

As DiapDealer mentioned, if it would make things easier you might want to simply copy the get_image_size routine out of mobi_cover.py and paste it as a routine in your plugin.py and then remove all of the utf8utils, path.py, and mobi_cover.py so you don't have to keep those pieces around.

KindleUnpack (we) found that particular routine online in gpl, lgpl, and bsd versions so if you extract it you can pretty much claim any license you want for your code since you would not need anything else from KindleUnpack.

Thanks so much for your plugin! I will add it to the sticky list of plugins unless DiapDealer beats me to it!

KevinH
KevinH is offline   Reply With Quote
Old 04-18-2015, 12:55 PM   #14
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi All,

I have added Doitsu's latest plugin and my SanityChecker to the Sigil Plugin Index and cleaned it up a bit and added the short description from the plugin.xml for each.

Please let me know if anyone else has posted plugins that need to be added to the Sigil plugin index.

Thanks!

KevinH
KevinH is offline   Reply With Quote
Old 04-18-2015, 01:10 PM   #15
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
As DiapDealer mentioned, if it would make things easier you might want to simply copy the get_image_size routine out of mobi_cover.py and paste it as a routine in your plugin.py.
I originally tried to use the mobi_cover.py version that you recommended but I had problems with missing imports and decided to simply use the KindleUnpack version. After all, it's more or less a throwaway plugin that doesn't really do much.

Quote:
Originally Posted by KevinH View Post
KindleUnpack (we) found that particular routine online in gpl, lgpl, and bsd versions so if you extract it you can pretty much claim any license you want for your code since you would not need anything else from KindleUnpack.
However, without KindleUnpack (and your help) I wouldn't have found that routine. IMHO, it's only fair to mention that the most sophisticated part of the plugin code wasn't written by me.
Doitsu is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help with text wrap... skammer1974 Sigil 3 03-06-2013 07:28 PM
TEXT WRAP AROUND IMAGES RKEP71 Sigil 1 06-20-2011 08:26 PM
Image wrap test Jellby ePub 15 05-04-2011 02:30 PM
LRF and wrap-around text Seabound Calibre 13 12-28-2008 03:30 PM


All times are GMT -4. The time now is 01:40 AM.


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