10-26-2015, 10:07 AM | #1 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
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() dummyimg.open(path_to_img_on_PC) dummyimg.size = (wid, hgt) dummyimg.save(path_to_exploded_ebook_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 |
10-26-2015, 11:01 AM | #2 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
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) |
Advert | |
|
10-26-2015, 11:16 AM | #3 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Looks easy enough. Thanks
|
10-26-2015, 11:27 AM | #4 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
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? |
10-26-2015, 11:47 AM | #5 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
yes, get_resources() is a global function, vaialbale throughout plugin code
|
Advert | |
|
10-27-2015, 08:00 AM | #6 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
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 currlib_path = db.library_path |
10-27-2015, 08:11 AM | #7 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
self.gui.iactions['Choose Library'].stats.stats
|
10-27-2015, 08:29 AM | #8 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Thanks
|
10-27-2015, 12:31 PM | #9 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Back again ...
To date when I've wanted to include an ebook preview dialog I've used something like Code:
webview = QWebView() name = 'xyz' webview.load(QUrl.fromLocalFile(container.name_path_map[name])) Code:
webview.reload Since 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 |
10-27-2015, 01:40 PM | #10 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That's fine. Although, you should be using name_to_abspath() rather than name_path_map.
|
10-27-2015, 02:01 PM | #11 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
OK, will do. Thanks
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Plugin for video, audio, and image files? | woodr2011 | Plugins | 0 | 09-24-2015 07:51 AM |
Using image in plugin code | Jellby | Development | 7 | 03-11-2014 10:56 PM |
Plugin Dev - Examples/Resources | adamtg | Development | 2 | 05-07-2013 11:23 PM |
Calibre system resources used | audeojude | Calibre | 3 | 01-07-2013 09:27 AM |
calibre Help Resources | unboggling | Calibre | 0 | 10-17-2012 11:12 AM |