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 11-07-2015, 07:55 PM   #1
dhdurgee
Guru
dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.
 
Posts: 825
Karma: 2525050
Join Date: Jun 2010
Device: K3W, PW4
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
dhdurgee is online now   Reply With Quote
Old 11-13-2015, 07:47 AM   #2
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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
[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 Pillow
The Linux version of the plugin requires the gtk Python package and the gtk libraries. (Both gtk2 and gtk3 are supported.)

Unfortunately, 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)
Attached Files
File Type: zip PasteImage_v0.2.1.zip (1.7 KB, 2790 views)

Last edited by Doitsu; 08-16-2017 at 03:11 AM. Reason: New version with autostart enabled (Sigil 0.9.3+ required)
Doitsu is offline   Reply With Quote
Advert
Old 11-13-2015, 09:28 AM   #3
dhdurgee
Guru
dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.
 
Posts: 825
Karma: 2525050
Join Date: Jun 2010
Device: K3W, PW4
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
dhdurgee is online now   Reply With Quote
Old 11-13-2015, 01:03 PM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Doitsu -- for python2+3 you can use:

Code:
from gi.repository import Gtk, Gdk
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
image = cb.wait_for_text()
PyGtk is deprecated (that's why there is no python3 version) and they want you to use PyGObject instead.

Last edited by eschwartz; 11-13-2015 at 01:11 PM.
eschwartz is offline   Reply With Quote
Old 11-13-2015, 01:07 PM   #5
dhdurgee
Guru
dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.dhdurgee ought to be getting tired of karma fortunes by now.
 
Posts: 825
Karma: 2525050
Join Date: Jun 2010
Device: K3W, PW4
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
dhdurgee is online now   Reply With Quote
Advert
Old 11-13-2015, 01:17 PM   #6
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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by dhdurgee View Post
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"
Thanks for the bug report. I've attached a fixed version to the second post.
Doitsu is offline   Reply With Quote
Old 11-13-2015, 02:03 PM   #7
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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by eschwartz View Post
Doitsu -- for python2+3 you can use:

Code:
from gi.repository import Gtk, Gdk
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
image = cb.wait_for_text()
Thanks for the suggestion. I'd actually experimented with the following similar code:

Code:
import tempfile
from gi.repository import Gtk, Gdk
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
img = clipboard.wait_for_image()

if img:    
    temp_file = tempfile.NamedTemporaryFile().name
    img.save(temp_file, 'jpeg')
but I got a weird error message for img.save() that I couldn't resolve:

Code:
AttributeError: 'Pixbuf' object has no attribute 'save'
Error: 'Pixbuf' object has no attribute 'save'
even though img is a Gtk 3.0 gi.repository.GdkPixbuf.Pixbuf object, which definitely should have a save attribute.
Doitsu is offline   Reply With Quote
Old 11-13-2015, 02:16 PM   #8
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
What lunacy.

Apparently the documentation is wrong, and you should use
Code:
img.savev(filename, image_type, ['quality'], ['100'])
https://stackoverflow.com/questions/...used-in-python

Last edited by eschwartz; 11-13-2015 at 02:23 PM.
eschwartz is offline   Reply With Quote
Old 11-14-2015, 08:13 AM   #9
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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by eschwartz View Post
Apparently the documentation is wrong, and you should use
Code:
img.savev(filename, image_type, ['quality'], ['100'])
Thanks to your superior Google Fu, I was able to make this most important of all Sigil plugins Python 3.4 compatible for Linux users.

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.
Doitsu is offline   Reply With Quote
Old 11-14-2015, 11:25 PM   #10
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)


Any particular reason you use different methods for PY2 (pygtk) vs PY3 (gi.repository)?
Just curious.
eschwartz is offline   Reply With Quote
Old 11-15-2015, 01:40 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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by eschwartz View Post
Any particular reason you use different methods for PY2 (pygtk) vs PY3 (gi.repository)?
I decided to include Python 2.7 + gtk mainly for backwards compatibility, because not every Linux user has a bleeding edge distro with the latest libraries.

Also, IMHO, the additional if-then import statements make this plugin look more sophisticated.
Doitsu is offline   Reply With Quote
Old 11-15-2015, 01:53 AM   #12
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Sophistication.
eschwartz is offline   Reply With Quote
Old 11-21-2015, 12:26 AM   #13
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,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
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.
Doitsu is offline   Reply With Quote
Old 11-21-2015, 06:56 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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Added this to Sigil Plugin Index sticky
KevinH is offline   Reply With Quote
Old 11-28-2015, 11:10 AM   #15
SHunter101
Connoisseur
SHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel isSHunter101 really knows where his or her towel is
 
Posts: 56
Karma: 70350
Join Date: May 2013
Device: Kobo AuraH2O, Glo, AuraHD, JBC2
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
SHunter101 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
[GUI Plugin] Clipboard Search kiwidude Plugins 24 03-16-2024 11:06 PM
new feature request - paste image support dhdurgee Sigil 16 11-22-2015 06:29 AM
Troubleshooting Paste wifi password into text file? garyyoung Amazon Kindle 9 07-08-2014 12:15 AM
How do I copy and paste an image into the body? Gregg Bell Feedback 26 02-06-2013 10:42 PM
copy and paste with image pdf kab enTourage Archive 12 04-27-2010 02:32 PM


All times are GMT -4. The time now is 12:35 PM.


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