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 06-05-2019, 09:35 PM   #76
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,463
Karma: 192992430
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)
to:
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)
to:
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.
DiapDealer is offline   Reply With Quote
Old 06-06-2019, 12:24 AM   #77
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 667
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
Quote:
Originally Posted by Queen Fiona View Post
Why are the viewBox and image size tags so much smaller than the actual image?
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.
AlanHK is offline   Reply With Quote
Advert
Old 06-06-2019, 07:06 AM   #78
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,463
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by AlanHK View Post
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.
It's a bug in the plugin that i documented in the post immediately prior to yours. It may "work" in iBooks and KindleBooks, but unnecessarily limiting the dimensions of SVG wrapped images to a maximum of 400px is definitely not the way it's supposed (or intended) to work.

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.
DiapDealer is offline   Reply With Quote
Old 06-07-2019, 12:47 AM   #79
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 667
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
Quote:
Originally Posted by DiapDealer View Post
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.
I don't think so -- the images seem sharp as original. I've used it in several books and would feel compelled to redo the images if they are indeed downsampled and not just rescaled. The whole reason I used SVG is to get maximum size without distortion.

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>
I copied this file and made it:

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>
Comparing them on screen, see two lines in both.
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>
It might however distort the image slightly as the aspect ratio becomes less precise with smaller numbers.

Last edited by AlanHK; 06-07-2019 at 04:22 AM.
AlanHK is offline   Reply With Quote
Old 06-07-2019, 05:51 AM   #80
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,463
Karma: 192992430
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.
DiapDealer is offline   Reply With Quote
Advert
Old 06-28-2019, 03:01 PM   #81
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,583
Karma: 4300000
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.
odamizu is offline   Reply With Quote
Old 06-28-2019, 03:32 PM   #82
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,463
Karma: 192992430
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?
DiapDealer is offline   Reply With Quote
Old 06-28-2019, 04:35 PM   #83
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,583
Karma: 4300000
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)
Attached Thumbnails
Click image for larger version

Name:	image 1.png
Views:	238
Size:	53.2 KB
ID:	172165   Click image for larger version

Name:	image 2.png
Views:	219
Size:	64.3 KB
ID:	172166   Click image for larger version

Name:	image 3.png
Views:	221
Size:	125.2 KB
ID:	172167  

Last edited by odamizu; 06-28-2019 at 04:54 PM. Reason: shrink image size, sorry
odamizu is offline   Reply With Quote
Old 06-28-2019, 10:19 PM   #84
asleyam
Enthusiast
asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.asleyam is less competitive than you.
 
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.
asleyam is offline   Reply With Quote
Old 06-28-2019, 11:21 PM   #85
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
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?
KevinH is offline   Reply With Quote
Old 06-28-2019, 11:52 PM   #86
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,463
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Tk as far as I know (without looking).
DiapDealer is offline   Reply With Quote
Old 06-28-2019, 11:59 PM   #87
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,583
Karma: 4300000
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by asleyam View Post
... have the same issue as described by odamizu ... In my case it only impacts jpegs ...
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 )
odamizu is offline   Reply With Quote
Old 06-29-2019, 06:37 AM   #88
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,463
Karma: 192992430
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.
DiapDealer is offline   Reply With Quote
Old 06-29-2019, 08:41 AM   #89
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
Mac Users - please make sure you have installed ActiveState's ActiveTCL for Mac version 8.6.x just to doublecheck.
KevinH is offline   Reply With Quote
Old 06-29-2019, 09:02 AM   #90
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,463
Karma: 192992430
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.
DiapDealer 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
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


All times are GMT -4. The time now is 07:54 AM.


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