06-05-2019, 09:35 PM | #76 |
Grand Sorcerer
Posts: 27,903
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
He's inadvertently thumbnailing self.img with PIL (to display it in the Tk widget). So when self.img.size is called later on, the new smaller thumbnail size is the one being returned.
Lots of different ways to tackle correcting it. A down-and-dirty-way to get it going would be to make a few similar changes in two different locations. In plugin.py (latest version) starting with line #255 change: Code:
self.img = Image.open(BytesIO(bkImage)) size = 400, 400 self.img.thumbnail(size, Image.ANTIALIAS) self.photo = ImageTk.PhotoImage(self.img) Code:
img_temp = Image.open(BytesIO(bkImage)) self.img = img_temp.copy() size = 400, 400 img_temp.thumbnail(size, Image.ANTIALIAS) self.photo = ImageTk.PhotoImage(img_temp) And in plugin.py line #275 (before the above change) change: Code:
self.img = Image.open(filehandle.name) size = 400, 400 self.img.thumbnail(size, Image.ANTIALIAS) self.photo = ImageTk.PhotoImage(self.img) Code:
img_temp = Image.open(filehandle.name) self.img = img_temp.copy() size = 400, 400 img_temp.thumbnail(size, Image.ANTIALIAS) self.photo = ImageTk.PhotoImage(img_temp) Last edited by DiapDealer; 06-05-2019 at 09:55 PM. |
06-06-2019, 12:24 AM | #77 |
Guru
Posts: 674
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
It's always been like that -- I know nothing about SVG, but I assumed it was a virtual page that was scaled up to whatever the real size is; since it does seem to work in iBooks and converted to AZW3.
|
Advert | |
|
06-06-2019, 07:06 AM | #78 | |
Grand Sorcerer
Posts: 27,903
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
It was an easy mistake to make. It's not immediately clear that the image.thumbnail() function of Pillow is actually altering the original image, rather than returning a new, smaller copy of it. |
|
06-07-2019, 12:47 AM | #79 | |
Guru
Posts: 674
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
Quote:
So I hope what it is doing now can be clarified: does it downsample to 400px? PS-- did some tests. I made a PNG with 1 px lines 1 px apart, image size 800x800. the SVG plugin made: Code:
<div><svg xmlns="http://www.w3.org/2000/svg" height="100%" width="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 400 400" xmlns:xlink="http://www.w3.org/1999/xlink"> <image width="400" height="400" xlink:href="../Images/bigtest.png"/> </svg> </div> Code:
<div><svg xmlns="http://www.w3.org/2000/svg" height="100%" width="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 800 800" xmlns:xlink="http://www.w3.org/1999/xlink"> <image width="800" height="800" xlink:href="../Images/bigtest.png"/> </svg></div> If I resize the PNG in PhotoShop to 400x400, the lines blur into each other, as the gap becomes 0.5 px. So, the plugin isn't resampling. It's silly, but not degrading the image. PPS-- Took it the other way and made the "thumbnail" size even smaller. All looked fine, even down to: Code:
<div><svg xmlns="http://www.w3.org/2000/svg" height="100%" width="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 1 1" xmlns:xlink="http://www.w3.org/1999/xlink"> <image width="1" height="1" xlink:href="../Images/bigtest.png"/> </svg></div> Last edited by AlanHK; 06-07-2019 at 04:22 AM. |
|
06-07-2019, 05:51 AM | #80 |
Grand Sorcerer
Posts: 27,903
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
No. The image itself is not being downsampled. The SVG wrapper is limiting the viewbox to 400 pixels on the longest side. Which is essentially the same thing for display purposes. The plugin is making a mistake in this regard. There's no question about that. I've posted a potential fix.
|
Advert | |
|
06-28-2019, 03:01 PM | #81 |
just an egg
Posts: 1,655
Karma: 5432100
Join Date: Mar 2015
Device: Kindle, iOS
|
When using this plugin with 0.9.15 (beta), I get the following error message: "You must select an image from the list or load a file or press Close".
I have selected an image from the list, and yet this message persists. I don't use this plugin often, so not sure if this problem is new with 0.9.15, but thought I'd report it. I'm on a Mac (High Sierra), if that makes a difference. |
06-28-2019, 03:32 PM | #82 |
Grand Sorcerer
Posts: 27,903
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Seems to working as expected on on Windows with 0.9.15. Can you document the exact steps you're taking?
|
06-28-2019, 04:35 PM | #83 |
just an egg
Posts: 1,655
Karma: 5432100
Join Date: Mar 2015
Device: Kindle, iOS
|
1) Plugins > Edit > InsertImageSVG
2) Select image — note: image does not appear in the plugin's preview pane, which remains blank (see 1st image attachment) 3) Click "Insert" 4) Get error message (2nd image attachment) I tried this with an image already imported in the epub and also using the "Import external image" button. I also tried changing the position ("At the start," "At the end," etc.) but that didn't make a difference. Finally, when I tried re-sizing the plugin window, the preview pane goes from blank to showing some distortion (3rd image attachment) Last edited by odamizu; 06-28-2019 at 04:54 PM. Reason: shrink image size, sorry |
06-28-2019, 10:19 PM | #84 |
Enthusiast
Posts: 35
Karma: 14720
Join Date: Mar 2016
Device: kindle voyage, Kobo Forma, Kobo Aura One
|
I have migrated from a late 2015 iMac to a 2019 i9-9900K CPU @ 3.60GHz with 40gb ram and have the same issue as described by odamizu in the above post, with the difference that it now occurs in both the sigil beta (running in a newly installed mohave vm) and .14. In my case it only impacts jpegs. Other image formats will insert correctly. The error message in the plugin details is:
Code:
objc[1904]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fffa8ae13c8) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x10a57af50). One of the two will be used. Which one is undefined. Last edited by DiapDealer; 06-28-2019 at 11:56 PM. |
06-28-2019, 11:21 PM | #85 |
Sigil Developer
Posts: 8,099
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Maybe a broken Pillow library?
I will try this plugin tomorrow on my Mac dev machine and see if changing PiL/Pillow version matters. Does this plugin use PyQt5 or tk graphics? |
06-28-2019, 11:52 PM | #86 |
Grand Sorcerer
Posts: 27,903
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Tk as far as I know (without looking).
|
06-28-2019, 11:59 PM | #87 |
just an egg
Posts: 1,655
Karma: 5432100
Join Date: Mar 2015
Device: Kindle, iOS
|
How interesting. I only tested it with jpgs. Just tried a png, and the plugin works fine with png. Haven't tried other image formats, but I take asleyam's word for it that this is a jpeg issue. (Also glad it's not just me )
|
06-29-2019, 06:37 AM | #88 |
Grand Sorcerer
Posts: 27,903
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
And I can't swear that I tested with anything other than pngs. I'll try again in a bit.
|
06-29-2019, 08:41 AM | #89 |
Sigil Developer
Posts: 8,099
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Mac Users - please make sure you have installed ActiveState's ActiveTCL for Mac version 8.6.x just to doublecheck.
|
06-29-2019, 09:02 AM | #90 |
Grand Sorcerer
Posts: 27,903
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Just checked again with jpegs to be certain, and it still works for me on on Windows (bundled Pillow v5.4.1) and on Linux (system Pillow v6.0.0).
I'd focus on making sure the following works in general on the Macs in question (with the bundled version of Pillow): Code:
from PIL import Image, ImageTk image = Image.open("image.jpg") photo = ImageTk.PhotoImage(image) Last edited by DiapDealer; 06-29-2019 at 10:59 AM. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wrap in SVG plugin? | gezginrocker | Plugins | 18 | 07-05-2015 12:20 AM |
svg image on top of a background png image | roger64 | ePub | 25 | 04-24-2015 11:00 AM |
Display of a png image linked to a svg image | roger64 | Editor | 6 | 03-13-2015 06:21 AM |
Image wrap test | Jellby | ePub | 15 | 05-04-2011 02:30 PM |
Combining blockquote with image wrap | WRB | Sigil | 1 | 02-12-2011 07:46 PM |