![]() |
plugin to paste an image file from clipboard
I believe an edit plugin could be created to retrieve an image from the clipboard and save it in the epub Images. I lack knowledge in Python, the interfaces to the clipboard and the tools to work with the epub from the plugin, so I am hoping that someone else might be interested in creating such a plugin.
The incentive for this plugin is to make it simpler to incorporate images that are not already stored on the computer, typically from the internet, into the epub being edited by Sigil. The current method of incorporating such images involves saving them to a file, incorporating that file into the epub and deleting the no longer needed file. Copying the image to the clipboard and then using the plugin to incorporate it into the epub simplifies this greatly. Dave |
1 Attachment(s)
[Plugin] PasteImage - Adds images from the clipboard
Updated: December 22, 2015 Current Version: "0.2.1" This is a very simple image pasting plugin that'll add clipboard images to the currently loaded epub as .jpg images (regardless of the original format). Installation: Select Plugins > Manage Plugins > Add Plugin > PasteImage.zip If you're using the Windows version of Sigil 0.9.0 (or higher) select Use Bundled Python. If you're using an older Sigil version, you'll need to install a Python interpreter and the Pillow package. To install Pillow open an admin command prompt and enter the following command: Code:
pip install PillowUnfortunately, the plugin is not fully compatible with OSX. You can't copy images via the system clipboard, however, you can copy images via browser image URLs. (Right-click the image in the browser and select Copy Image Location/URL.) Usage: Copy an image or an image URL to the clipboard and select Plugins > Edit > PasteImage. Known issues: The plugin won't work with all apps. For example, you can't paste images copied from Google Chrome (Firefox works). You also might get a "Pillow import error" message even though Pillow is installed, if Pillow can't handle the image. The jpeg image quality is hard-coded, but it can easily be changed by editing the quality value in plugin.py. License: GNU General Public License v3 (GPL-3) |
I just installed and tested this on my system, Linux Mint 17.1 rebecca x64 Cinnamon, and tested it with an image from SeaMonkey 2.39 and it worked as designed. Thank you for a quick response to my request for assistance.
Dave |
Doitsu -- for python2+3 you can use:
Code:
from gi.repository import Gtk, Gdk |
Now that I have tried it on a few real examples I have run into one minor thing I needed to fix in the plugin.py:
On line 41 there is a "png" that should be "jpeg" Once I fixed that I am no longer getting validation errors. Dave |
Quote:
|
Quote:
Code:
import tempfileCode:
AttributeError: 'Pixbuf' object has no attribute 'save' |
What lunacy. :)
Apparently the documentation is wrong, and you should use Code:
img.savev(filename, image_type, ['quality'], ['100']) |
Quote:
I've attached a new version to the second post. Windows users won't need to download this updated version, because it fixes a Linux-only issue. |
:D
Any particular reason you use different methods for PY2 (pygtk) vs PY3 (gi.repository)? Just curious. |
Quote:
Also, IMHO, the additional if-then import statements make this plugin look more sophisticated. :D |
Sophistication. :cool:
|
I've added partial OSX support to the plugin. The new version (attached to the second post) allows you to copy web browser images via the image URL. Simply right-click an image in your web browser, select Copy Image Location/URL and then select Plugins > Edit > PasteImage.
Of course, this feature also works with the Windows and Linux versions of Sigil. |
Added this to Sigil Plugin Index sticky
|
Thanks for the cool plugin. I have a feature request. I would like the ability to paste the image from clipboard to where I have positioned the cursor. Not sure if that is possible.
SH |
| All times are GMT -4. The time now is 08:52 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.