MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   [Plugin] AddImgasSVG (https://www.mobileread.com/forums/showthread.php?t=268878)

rubeus 12-21-2015 04:39 AM

[Plugin] AddImgasSVG
 
Hi,

Doitsu has published a plugin to select an image which is then inserted as a complete new page wrapped in SVG to fill the entire screen retaining the aspect ratio. This is the same way the Add Cover menu item is working, but without adding the semantics.

The original Version can be found here:

https://www.mobileread.com/forums/sho...d.php?t=255300

At first some honorable mentions:
  • Doitsu for his first version
  • KevinH for his patience
  • diapdealer and eschwarz for giving some nice tips'n'tricks

The way of publishing the enhanced version was Doitsu's proposal.

What has been enhanced?
  • the list in the dropdown menu is sorted
  • there are no other libs needed any more, imagesize determined with PIL
  • bug with non-unique filenames/ids fixed
  • existent cover.xhtml template used if present in sigil's preference environment

What is the disadvantage? My Version is Python >3 only. This and the PIL library are present when using Sigil > 0.9.1 using the internal python interpreter. If you still want to use Python 2.7 you need to install Doitsu's version which can be found in the thread linked above.

KevinH 12-21-2015 07:14 AM

BTW, if all you need from PIL is image size info, you might want to check out the python code in KindleUnpack that handles generation of covers called mobi_cover.py.

It can be found here:
https://github.com/kevinhendricks/Ki.../mobi_cover.py

There is a bug fixed image type identifier and the original image size routine that PIL used to create their version that was written by Draco.

If you use that version, you may not need PIL at all.

rubeus 12-21-2015 07:52 AM

Using PIL offers the possibility to create an enhanced user interface showing thumbnails. Maybe in 5 years or so :rofl:

rubeus 12-25-2015 07:46 AM

3 seconds after publishing the 010 version i got suggestions for new improvements :rofl:

Ok, here we go
  • Added the possibility to insert an image from disk which is wrapped in an SVG
  • prepared for autostart and autoclose launcher window
  • user interface improved

Version 020 added to #1

rubeus 01-04-2016 02:57 AM

New Version in #1
  • It's possible to select more than on image to be wrapped
  • The position where the wrapped images should be inserted can be chosen
  • Below the thumbnail there is some information about the active picture

roger64 01-10-2016 05:01 AM

Hi

Thank you for your work.

I did try it but it failed for a missing module.

Code:

Statut :failed

Traceback (most recent call last):
  File "/usr/share/sigil/plugin_launchers/python/launcher.py", line 134, in launch
    target_script = __import__(script_module)
  File "/home/roger/.local/share/sigil-ebook/sigil/plugins/AddImgasSVG/plugin.py", line 9, in <module>
    from PIL import Image
ImportError: No module named 'PIL'
Error: No module named 'PIL'

I use Sigil 9.2 (Archlinux 64 bits build)

Edit: I realize have version 0.1; I will install 03 and report back.
Sorry

roger64 01-10-2016 05:10 AM

I installed the brand new 0.3 (which is still reported as 0.2) but the error message is the same.

rubeus 01-10-2016 05:52 AM

Did you install PIL? Are you using the internal Python Interpreter?

Doitsu 01-10-2016 06:43 AM

Quote:

Originally Posted by roger64 (Post 3237669)
I installed the brand new 0.3 (which is still reported as 0.2) but the error message is the same.

Depending on the Python interpreter(s) you've installed, you'll need to enter the following command(s) in a Terminal window:

Code:

sudo pip install Pillow
(Python 2.7)

Code:

sudo pip3 install Pillow
(Python 3.4)

rubeus 01-10-2016 08:34 AM

This Version does not run with Python 2.7...

DiapDealer 01-10-2016 09:25 AM

Keep in mind that the Linux version of Sigil does not have a bundled (internal) Python interpreter. Check out the BuildingOnLinux docs at github to see what additional Python modules you'll need to install to meet the minimum requirements for a basic Sigil plugin environment on Linux.

And in this case, since the developer indicates that his plugin does not support Python 2, you'll want to install the modules with pip3.

roger64 01-10-2016 09:34 AM

1 Attachment(s)
Thank you all. I knew nothing about Mr PIL.


It works perfectly well with 3.4 -64 bits- (and the idea to place it either on first page, last page, page before or after is excellent). I joined a copy of what I had to install on Arch.I did not need to install the huge optional package (see screenshot).

:thumbsup:

eschwartz 01-22-2016 01:42 AM

Do note that I, the sigil-git AUR maintainer, explicitly listed python-pillow as an optdepends.

With the message that it is one of several modules *recommended* if you are going to be using plugins.

Please keep in mind when running plugins in Sigil on Arch Linux, that if you haven't installed the optdepends you may run into problems where plugins expect a module that you have *chosen* to skip installing.
User centrism gives you the power to shoot yourself in the foot if you don't pay attention...

KevinH 01-22-2016 11:18 AM

FWIW, I strongly recommend these python3 packages be required not optional. Sigil is going to start using its embedded python interpreter more to implement many of the epub3 related features. Especially when it tries to implement support for fixed format epubs. So even internal Sigil python code, not just plugins, will start to use those packages the way they use lxml right now. It will also reduce the number of bug reports on linux like this one.

Thanks,
KevinH

roger64 01-22-2016 11:36 AM

@KevinH, eschwartz

Thanks for the advice. I will install these optional packages. :)


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

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.