![]() |
Calibre plugin image resources
I'm trying to convert a Python script (run via calibre-debug -e) to a plugin and am having a bit of trouble translating the image processing.
In the script I was using: Code:
dummyimg = Image()In previous plugins, using the 'copy-something-someone-else-did' method, I've used code in the genesis method like Code:
self.icons = get_icons(['images/plugin_icon.png', 'images/pic1.png', ...])Does the way I pass the images to the plugin need to change in genesis or do I need a way of converting the QIcon() data from get_resources('images/pic1.png') to an instance of Image() ? Advice, please :) |
Use get_resources instead of get_icons that will get you the raw image data which you can use with the Image object as
img.load(data) instead of image.open(data) but if all you want to do is resize and save the image, the QIcon class is perfectly capable of doing that, like this qicon.pixmap(width, height).save(path to file) |
Looks easy enough. Thanks :)
|
Followup question...
get_resources is available to the top level main Class. If the main Class calls another Class which calls another Class ... etc Is the get_resources() method still available to the lower level Classes? |
yes, get_resources() is a global function, vaialbale throughout plugin code
|
Question re: calibre library paths.
When running a plugin from calibre library X, is there a way to query calibre for a list of other library paths it knows about? I'm familiar with this for the current library path: Code:
db = self.gui.current_db |
self.gui.iactions['Choose Library'].stats.stats
|
Thanks :)
|
Back again ...
To date when I've wanted to include an ebook preview dialog I've used something like Code:
webview = QWebView()Code:
webview.reloadSince I'm trying to do things 'the calibre way' in this little exercise, please can you advise whether I should be doing something different. Thanks in advance :) |
That's fine. Although, you should be using name_to_abspath() rather than name_path_map.
|
OK, will do. Thanks :)
|
| All times are GMT -4. The time now is 08:29 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.